Skip to main content

bizstd

An append-only container for records that arrive continuously and are read back in bulk.

pip install bizstd

A file is a fixed binary preamble, a text header zone edited in place, and a data section of independent zstd frames followed by an uncompressed tail. Records are appended to the tail as they arrive; when a period ends the tail is compressed into a frame. Both steps are crash-safe, and every frame carries a checksum.

Writing

import bizstd

schema = bizstd.Schema(
    "samples@1",
    [
        bizstd.FieldSpec("time_nanos", "u64", 0),
        bizstd.FieldSpec("value", "f64", 8),
    ],
    bizstd.RecordLayout.fixed(16),
)

with bizstd.create("samples.bizstd", schema, source="sensor", writer="demo") as file:
    for record in incoming:
        file.append(record)
    file.close_frame(0)

Reading

with bizstd.open_read("samples.bizstd") as file:
    print(file.headers["_schema"], file.record_count)
    for record in file:
        ...

Frames are addressed by position, not by id: ids belong to the writer and writers repeat them. file.frame(0) is the first frame; file.frame_by_id(3) is there for when you mean one particular frame.

Errors

Every failure is a subclass of BizstdError, and the subclasses are the distinctions worth acting on:

Exception Means
BizstdMalformedError the file is not a well-formed container
BizstdUsageError the calling code asked for something it may not
BizstdZoneFullError the header zone is full — repack with a larger one
BizstdCompressionError zstd refused
OSError the operating system said no

Typing

Fully typed, py.typed in both packages, checked with mypy --strict. The extension module ships hand-written stubs that a test compares against the real module, so they cannot drift quietly.

Concurrency

One writer per file, and enforcing that is your job — nothing here takes a lock, and two writers on one path corrupt it silently. Readers are unrestricted among themselves.

Packages

bizstd is pure Python and depends on bizstd-binary, which is the compiled extension and nothing else. The split means a platform without a prebuilt wheel fails with a clear message instead of hunting for a compiler, and it means this package can be read and patched without a build matrix.

MIT. Source, the format specification and the benchmarks behind the choice of zstd: https://github.com/aliaksandr-master/bizstd_rs

Release files for bizstd 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bizstd 2.0.0
File Size Uploaded
bizstd-2.0.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bizstd 2.0.0
File Interpreter ABI Platform
bizstd-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / bizstd-2.0.0.tar.gz

Download URL bizstd-2.0.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fccbf811b06bc373631c627e61948f5b79436b6c252bf42b67d0a03d498ae50f
BLAKE2b-256 checksum
How to use checksums
bd27f54a44ac045e5b1dd32d3942bf98150d32dcd63bb5fa53180ebebae4ff3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / bizstd-2.0.0-py3-none-any.whl

Download URL bizstd-2.0.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8659cf6f03a2f988e24699c8bb0715ecfd1eef80446d204083eeff5d4e084701
BLAKE2b-256 checksum
How to use checksums
840327804aafd24acab8e097a5c90c16bd9fef7e6a9c986585bbe820e3d07686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release history Release notifications | RSS feed

2.1.0

2 release files

This release

2.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page