Skip to main content

High-performance bitemporal data processing for Python

Project description

PyTemporal

High-performance bitemporal data processing for Python

PyTemporal is a Rust-powered library for processing bitemporal timeseries data with world-class performance (157,000+ rows/second). Perfect for financial services, audit systems, and applications requiring immutable data trails with both business and system time dimensions.

Quick Start

# Install from source
git clone <your-repo>
cd pytemporal
uv run maturin develop --release
import pandas as pd
from pytemporal import BitemporalTimeseriesProcessor

# Initialize processor
processor = BitemporalTimeseriesProcessor(
    id_columns=['id'],
    value_columns=['price']
)

# Process temporal updates
result = processor.process_updates(
    current_state=current_df,
    updates=updates_df, 
    system_date='2025-01-27'
)

print(f"Updated {len(result.to_insert)} records")

Key Features

  • ๐Ÿš€ World-Class Performance: 157,000+ rows/second throughput
  • ๐Ÿ”„ Bitemporal Processing: Track both business time and system time
  • ๐Ÿ Python-First: High-level DataFrame API with pandas integration
  • โšก Zero-Copy: Apache Arrow columnar format for memory efficiency
  • ๐Ÿ”ง Flexible Schema: Configure ID and value columns dynamically
  • ๐ŸŽฏ Two Update Modes: Delta updates or full state replacement
  • ๐Ÿ”€ Smart Conflation: Optional merging of consecutive records with identical values
  • ๐Ÿ—๏ธ Production Ready: Comprehensive test coverage and clean architecture

Documentation

What is Bitemporal Data?

Bitemporal data tracks two time dimensions:

  • Effective Time: When events occurred in the real world
  • As-Of Time: When information was recorded in the system

This enables powerful queries like "What did we think the price was on Jan 15th, as of Jan 20th?"

Use Cases

  • Financial Services: Price histories, portfolio valuations, risk calculations
  • Audit Systems: Immutable change tracking with full reconstruction capability
  • Regulatory Compliance: Time-accurate reporting for compliance requirements
  • Data Warehousing: Slowly changing dimensions with full history preservation

Performance

Dataset Size Processing Time Throughput Memory
800k ร— 80 cols 5.4 seconds 157k rows/sec ~14GB
100k ร— 20 cols 0.6 seconds 167k rows/sec ~2GB

Benchmarked on modern hardware with optimized settings

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Python DataFrameโ”‚โ”€โ”€โ”€โ–ถโ”‚ PyTemporal (Rust)โ”‚โ”€โ”€โ”€โ–ถโ”‚ Processed Resultsโ”‚
โ”‚ (Pandas)        โ”‚    โ”‚ โ€ข Arrow Columnar โ”‚    โ”‚ (DataFrame)     โ”‚  
โ”‚                 โ”‚    โ”‚ โ€ข Parallel Proc  โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚ โ€ข Timeline Logic โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Built With:

  • Rust: Core processing engine for maximum performance
  • Apache Arrow: Columnar data format for zero-copy operations
  • PyO3: Seamless Rust-Python integration
  • Rayon: Data parallelism for multi-core performance

Development

# Run tests
cargo test                                    # Rust tests
uv run python -m pytest tests/ -v           # Python tests

# Performance benchmarks  
cargo bench                                  # Detailed benchmarks
uv run python validate_refactoring.py       # End-to-end validation

# Build release
uv run maturin develop --release

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make changes and add tests
  4. Run the test suite: cargo test && uv run pytest
  5. Submit a pull request

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in PyTemporal by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Acknowledgments

Built with modern Rust performance engineering and extensive profiling to achieve world-class bitemporal processing speeds while maintaining clean, maintainable code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytemporal-1.4.20-cp312-cp312-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pytemporal-1.4.20-cp311-cp311-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pytemporal-1.4.20-cp310-cp310-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pytemporal-1.4.20-cp39-cp39-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

File details

Details for the file pytemporal-1.4.20-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pytemporal-1.4.20-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6e14a58b52d24c353ef4b8d853e34b876b48f7ac07f01b44ab5774b33a2a0902
MD5 e0da6f2b2d7ee8bda844dc78a047c42b
BLAKE2b-256 4c8a425d71a1d3aa83264dad9428f1b8281a6f9bcff6d7aa464bee6125cfdedf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytemporal-1.4.20-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: build-wheels.yml on gingermike/pytemporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytemporal-1.4.20-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pytemporal-1.4.20-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b385c0fae1a172fc8538090f18f9ead42c63097a7b6e5853ce0e9350e0db37f3
MD5 1b64efdb75d4608fa74e17ce5932a01c
BLAKE2b-256 a57a06160010cd2b2a509bf33c3afd89c20dd4bbeb64bbd660b8b1250d737bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytemporal-1.4.20-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: build-wheels.yml on gingermike/pytemporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytemporal-1.4.20-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pytemporal-1.4.20-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bf140e842e981752afdcf3f90bb085514c969fcc4d673dbc1070c7af6fdf59e1
MD5 11704886973b720ad50988fc36327ddf
BLAKE2b-256 c609db033b7d5c70687bba0a76dc53422d80a1b2cb0b8da9cc40a86ea3f81813

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytemporal-1.4.20-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: build-wheels.yml on gingermike/pytemporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytemporal-1.4.20-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pytemporal-1.4.20-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2c12762a7f1dde03e4e0a7d9cdd761394125a0920b00d72ca34dc7d1f0cf5584
MD5 5f8ba44f793e1a0ee4bb20ccd145cd5c
BLAKE2b-256 5cb3a66e6fd21e3b6bbd237fae73afe8ad022016b7e7bbcebe8dabb31b5f1850

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytemporal-1.4.20-cp39-cp39-manylinux_2_34_x86_64.whl:

Publisher: build-wheels.yml on gingermike/pytemporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page