Skip to main content

In-memory LSM-style time-indexed storage engine with CPython bindings.

Project description

Timelog

In-memory, LSM-inspired, time-indexed multimap for Python (C17 core + CPython extension).

License PyPI version Python versions Tests (PR) Packaging (PR) Coverage CodeQL Sanitizers Python 3.12+

Why Timelog

Timelog is built for timestamp-first workloads where the core operation is "everything in [t1, t2)".
It provides a native in-memory index with snapshot-consistent reads, out-of-order ingestion support, and sequenced range deletes.

At a high level, writes flow through mutable ingest state into immutable layers (memrun, L0, L1), while reads merge across layers with tombstone-aware filtering.
The design is LSM-inspired, but explicitly scoped to an embedded in-memory engine.

Installation

Install from PyPI:

pip install timelog-lib

Or with uv:

uv add timelog-lib

Distribution name is timelog-lib, import namespace stays timelog:

from timelog import Timelog

Quickstart: Streaming

from timelog import Timelog

log = Timelog.for_streaming(time_unit="ms")

# Auto-timestamp append
log.append({"event": "boot"})

# Operator-style explicit timestamp append
log[1_700_000_000_000] = {"event": "tick"}

# Half-open range query [t1, t2)
rows = list(log[1_700_000_000_000:1_700_000_000_001])
print(rows)

log.close()  # optional explicit cleanup

Quickstart: Correctness Semantics

from timelog import Timelog

log = Timelog(time_unit="ms")
log[10] = "A"
del log[5:15]              # delete [5, 15)
log[10] = "B"              # later insert at same ts

print(log[10])             # ['B']
print(list(log[0:20]))     # [(10, 'B')]

log.close()  # optional explicit cleanup

Timelog uses sequenced tombstones, so later inserts are not hidden by earlier deletes.

Core Guarantees

  • Time ranges are half-open: [t1, t2).
  • Reads are snapshot-consistent.
  • Concurrency model is single writer plus concurrent readers.
  • Duplicate timestamps are allowed (multimap semantics).
  • Write-path backpressure (TimelogBusyError) indicates the write was accepted; do not blind-retry the same write.

What Timelog Is (and Isn’t)

Timelog is:

  • an embedded, in-memory timestamp index,
  • optimized for append-heavy ingest and time-range retrieval,
  • implemented in C17 with first-party CPython bindings.

Timelog is not:

  • a durable storage engine,
  • a distributed TSDB,
  • a SQL query engine.

close() does not materialize unflushed writes. Call flush() first if you need all pending data materialized into immutable segments before shutdown.

API Snapshot

Core Python facade surface:

  • Constructors:
    • Timelog(...)
    • Timelog.for_streaming(...)
    • Timelog.for_bulk_ingest(...)
    • Timelog.for_low_latency(...)
  • Writes:
    • append(...)
    • extend(...)
    • log[ts] = obj
    • delete(t1, t2) / delete(ts)
    • cutoff(ts)
  • Reads:
    • log[t1:t2], log[t1:], log[:t2], log[:]
    • log[ts] / at(ts)
  • Introspection and views:
    • stats()
    • views(...)

See docs/python-api.md for the full behavior contract.

Threading and Backpressure

  • Writes and lifecycle operations must be externally serialized.
  • Snapshot iterators are safe for concurrent reads.
  • Background maintenance can run automatically (maintenance="background") or be controlled manually.
  • TimelogBusyError on write operations means accepted write + pressure signal, not "write lost".
  • Do not call close() concurrently with other operations on the same instance.

Architecture

Write Path                               Read Path
----------                               ---------
append/extend/delete                     snapshot + query([t1, t2))
      |                                           |
      v                                           v
  Memtable (mutable)  <--------------------  Snapshot view
      | seal
      v
  Memrun (immutable)
      | flush
      v
  L0 Segments (overlap)
      | compact
      v
  L1 Segments (windowed, non-overlap)

Reads plan sources across active + immutable layers, then run k-way merge with tombstone filtering based on sequencing/watermark state.
Flush and compaction bound read fan-out over time.
Deletes are logical tombstones; physical cleanup is deferred to maintenance.

Performance at a Glance

Historical snapshot (2026-02-15, Linux x86_64, Python 3.13.12, dataset 11,550,000 rows):

  • Batch ingest (A2): 191,105 records/sec
  • Full scan (B4): 18,088,679 records/sec
  • Append latency (K1, background): p99 = 672 ns

Results are workload-, configuration-, and hardware-dependent.

Methodology and context:

  • docs/PERFORMANCE_METHODOLOGY.md
  • docs/BENCHMARK_1GB_7PCT_OOO_UNIX.md
  • docs/BENCHMARK_REPORT.md
  • docs/performance.md

Complexity claims should be interpreted with stated assumptions. In practice:

  • append path is amortized O(1) at memtable layer,
  • point/range behavior approaches logarithmic seek + linear output scan when source fan-out is bounded by maintenance,
  • delete cost depends on tombstone interval state.

Documentation

  • Index: docs/index.md
  • Python API: docs/python-api.md
  • Configuration: docs/configuration.md
  • Error and retry semantics: docs/errors-and-retry-semantics.md
  • Performance methodology: docs/PERFORMANCE_METHODOLOGY.md
  • PyPI/release operations: docs/pypi-release.md

License

MIT. See LICENSE.

Contributing

PRs are welcome. Run core validation locally:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DTIMELOG_BUILD_PYTHON=ON -DTIMELOG_BUILD_PY_TESTS=ON
cmake --build build --target timelog_e2e_build --config Release -j 2
ctest --test-dir build -C Release --output-on-failure -R '^py_.*_tests$'
cmake -E env PYTHONPATH="$PWD/python" python -m pytest python/tests -q

Package build sanity:

python -m build
python -m twine check dist/*

Project details


Download files

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

Source Distribution

timelog_lib-1.0.1.tar.gz (551.1 kB view details)

Uploaded Source

Built Distributions

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

timelog_lib-1.0.1-cp314-cp314-win_amd64.whl (93.6 kB view details)

Uploaded CPython 3.14Windows x86-64

timelog_lib-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (99.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

timelog_lib-1.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (96.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

timelog_lib-1.0.1-cp314-cp314-macosx_11_0_arm64.whl (81.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

timelog_lib-1.0.1-cp314-cp314-macosx_10_15_x86_64.whl (89.9 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

timelog_lib-1.0.1-cp313-cp313-win_amd64.whl (91.8 kB view details)

Uploaded CPython 3.13Windows x86-64

timelog_lib-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (99.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

timelog_lib-1.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (96.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

timelog_lib-1.0.1-cp313-cp313-macosx_11_0_arm64.whl (81.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

timelog_lib-1.0.1-cp313-cp313-macosx_10_13_x86_64.whl (89.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

timelog_lib-1.0.1-cp312-cp312-win_amd64.whl (91.9 kB view details)

Uploaded CPython 3.12Windows x86-64

timelog_lib-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (99.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

timelog_lib-1.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (96.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

timelog_lib-1.0.1-cp312-cp312-macosx_11_0_arm64.whl (81.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

timelog_lib-1.0.1-cp312-cp312-macosx_10_13_x86_64.whl (89.8 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

Details for the file timelog_lib-1.0.1.tar.gz.

File metadata

  • Download URL: timelog_lib-1.0.1.tar.gz
  • Upload date:
  • Size: 551.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for timelog_lib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2e91b6f8568ecfbd1ae54165e1012ee92a359f159f9a197b5b4d1a5b6a3eda40
MD5 748637eaddf11578f38add7dc0d4eaa4
BLAKE2b-256 243ee668e50a95a8652adfa3cbc67c490ad623008642b06ccb5a57f0d6a0c520

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1.tar.gz:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2ef80e7bd383a4a8a468d44cf4db230f73b94d0730343da304e0f4e0b16b980e
MD5 c85c573ec0c5f9a29861087fee3f604e
BLAKE2b-256 875432df7e0716329672428cf7a0c7b4d5ca81616b50675cf6565674b189fd2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp314-cp314-win_amd64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b6bf941a7c1f0596096bebb89dbfd38250003e5bfca3e17311bcc79eb19751c
MD5 6116b38d5e8ef09ea00d7878e1655a0b
BLAKE2b-256 51235cc0be4ce813489fae17beb869d5eb1151a49dca5815b5c02a8779058af9

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2501d0338df91ed09b944635b44bc17773482a8973532aef042a5bb8fe7be08e
MD5 3acc96be0dc822808dcbf6912f2a202e
BLAKE2b-256 a884ad88df685496a0181774a8c740bc9f20a236705ca2b3588f9485c6c74cd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c03abca971f63db672531b155adbea097c45b5cd62d40c7aeb2c5edb1f658149
MD5 ccabdf23e48a40aab8e7c8d8510844a8
BLAKE2b-256 1bc59f25eb40aa42928b0f4c5e3173ae04c4df80c4d8eceb6c603dc23a9c3267

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 92d32c75df8148009b91d5cfa66c4e83c94a6a08993b68e7f994f09278172e9c
MD5 b3a4b5fade0f1077d847e0d833bb7c17
BLAKE2b-256 380dad8d4785fd3ca2b17036f21cfa034683c619e615b6b9aece204bc4d42187

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp314-cp314-macosx_10_15_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 50dbeeb397a286b87c5b886dbebb7cec51a5dcb3d66ab53a8c1a892428aadb3f
MD5 bc84156753e99703eb6129ff9e15c7a5
BLAKE2b-256 4835f36304d9143c60a3723894130aa280e311c147d06803e01e0e2453c47d85

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp313-cp313-win_amd64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ce14f71528bb8a969beb24480a8da81f6c1e3820be4b95dbb5946f1b136213c
MD5 5e06c484c2e8a0759c1ce2b63d2bdfb7
BLAKE2b-256 7d3de8e1616d72b809d956f631865d9f6791fa6c36bf5d74cf601e34a1beec66

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3b81fad1f86dd0b27b2059586591d587b2bca21c5e357cdf2919b68e2d23e5a1
MD5 ada371f6344e00ee695b24045524e1b3
BLAKE2b-256 f7636df4cfccd3ea8127372dc2c793cfa5f5822fcf069c7da389f41dddd75798

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 920fffd2cbfc23ad900c0763f2d5cf8234e6e357db1c48ca26c2a05cc3d2f5bf
MD5 37de2d8cc4521c2e4123012f7f6f7c59
BLAKE2b-256 def4b17f7e55d109c0453219f21412ca74efd2046acbf5154423b3c6f515109c

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8a08a0ad8a344cfea50cea9f498f580992296bb7cf1acd4911ba2f0e704aef22
MD5 e87522abcc1d5d9086433043ff551474
BLAKE2b-256 e9836b4a5735ea3a44dfd2943e88e2fa0b3542f2eb7cccfdf1c6dcd63e81a4fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c9bf038df51b7ad53c136e6add729eec98c98f418d02b15bcceb52c1832fab8d
MD5 1182a36a083a645eaed2d6d8713e376f
BLAKE2b-256 e8e0d40bf78dcd193288245d98252918952f9a40ed681ebda21f691a343f2916

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp312-cp312-win_amd64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 500e38eaeb8be837782765b91de0d581307192db9b7ac8415b8b52c210462c66
MD5 2e5b5f364f44a9b090a38f8b84b9a20d
BLAKE2b-256 93b4ee0edc1c1d1f36e8fe7a4436d184069d46a665d0a175d3f194e58466766f

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9a74546656ef53efc2d900b8e2c9d330b7634a61396c20918e2fd85004bdf626
MD5 d2e1a98a88b29aeba65d928a17d40198
BLAKE2b-256 f0654d2a76624c1936f55f26bed97d17f2d8086c74f961b2c3c7e9c77e204040

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b3daac7f33da9d7c0f20dedfb72b547b380bcccb43486997ea2e1468609ccac
MD5 aa4ada827c6198fa74e363dba67da39a
BLAKE2b-256 fef9a3ce8c0caebf2dfa408d2d446bbedb565078af035fc8622077c253223b04

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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

File details

Details for the file timelog_lib-1.0.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for timelog_lib-1.0.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 94383db4e2d4d41a2fc0f6e8b0b4b19b4547481bfcd98dbc1741032414bf6162
MD5 3d397c40a2576443e840359db04d93c5
BLAKE2b-256 e9f041d5fb017e32eb81c8f5052bc981bb82504fccde977e45b3265185c2f77c

See more details on using hashes here.

Provenance

The following attestation bundles were made for timelog_lib-1.0.1-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: release-pypi.yml on VldChk/timelog

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