bitcask-dataset
A small, append-only blob store on disk. Good fit if you want:
- random-access reads by index or optional key, without a million loose files on disk
- read-only
memoryviewreads: zero-copy when uncompressed, or LZ4-compressed by default - immutable shards: each
extendonly writes new files and updatesmanifest.json, so unlike a single HDF5 or LMDB file, syncing to S3 only uploads what's new - easy multiprocess reads (handles pickle down to their path and reopen on their own)
Works best for biggish blobs (KiB to MiB), small keys, and batch appends.
Not a good fit if you need deletes, overwrites, compaction, concurrent writers, Windows support, or more keys than fit in RAM per process.
Install
Requires Python 3.14+ on POSIX.
pip install bitcask-dataset
Example
from bitcask_dataset import BitcaskDataset
ds = BitcaskDataset.create("my-dataset", keyed=True)
ds.extend([
(b"image/1", image_bytes),
(b"image/2", more_image_bytes),
])
ds = BitcaskDataset("my-dataset") # settings come from the manifest
value = ds[b"image/1"] # read-only memoryview
# insertion order works too
value = ds.at(0)
key = ds.key_at(0)
len(ds)
b"image/1" in ds
Keys are optional (keyless is the default):
ds = BitcaskDataset.create("my-keyless-dataset")
ds.extend([image_bytes, more_image_bytes])
value = ds.at(0)
Keys and values can be any C-contiguous buffer (bytes, bytearray, a contiguous NumPy
array, ...).
API
BitcaskDataset.create(path, *, keyed=False, compression="lz4", max_shard_size=1 << 30)
BitcaskDataset(path)
ds.extend(entries)
ds[key]
ds.at(index)
ds.key_at(index)
len(ds)
key in ds
createneeds a missing or empty directory.BitcaskDataset(path)opens an existing dataset and readskeyed,compression, andmax_shard_sizefrom the manifest.extendtakes(key, value)pairs when keyed (duplicate keys are errors) and values directly when keyless. Eachextendis all-or-nothing and only writes new shards. Records aren't split, so a record overmax_shard_sizegets a shard to itself.- Values are compressed on a thread pool, so don't modify a value's buffer after
yielding it to
extend. - Keys and values come back as read-only
memoryviews, whichnp.frombufferandtorch.frombuffercan use without copying. Withcompression=None, values are views straight into the mmap with zero copies; non-empty compressed values are views of freshly decompressedbytes(value.obj). Keys are always uncompressed. atandkey_atsupport negative indexes. Key lookup (ds[key]) andkey_atraiseTypeErrorin keyless mode. Datasets aren't iterable.
Format
my-dataset/
manifest.json
000000.bin
000000.idx
000001.bin
000001.idx
manifest.json holds the settings and how many shards are committed:
{"keyed": true, "compression": "lz4", "max_shard_size": 1073741824, "shards": 2}
Each .idx lists its shard's records as little-endian uint32 sizes: key_size, value_size pairs when keyed, one stored-value size per record when keyless. Keyed
shards are key || value || key || value ...; keyless shards only contain values.
There are no record headers or padding. Values are independent LZ4 blocks using
high-compression mode, with the original size in each block. Empty values stay empty.
Rewriting the manifest commits an extend, so shard files it doesn't list are
leftovers from an interrupted extend; they're ignored and overwritten later. When
copying a dataset, copy the manifest last.
Keyed datasets copy keys into a Python dict in each process that opens them. Each key
and stored value is limited to 2**32 - 1 bytes; with LZ4, uncompressed values are also
limited to about 2 GiB, the LZ4 block limit.
Not actually an implementation of the Bitcask paper, though the per-shard index files are close to its hint files.
Dev
uv sync
make format
make lint
make test
Metadata
Release files for bitcask-dataset 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bitcask_dataset-0.3.1.tar.gz | 7.7 kB | Without provenance | Details for bitcask_dataset-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bitcask_dataset-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for bitcask_dataset-0.3.1-py3-none-any.whl |
Total release size: 15.7 kB
Release files / bitcask_dataset-0.3.1.tar.gz
| Download URL | bitcask_dataset-0.3.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d426de74f95269c1c617b4abad2819b7402107ce3fd28c0d9fda45f155c7211b
|
|
BLAKE2b-256 checksum How to use checksums |
94f9009d3de4900ab8848786ad80ab873ede24d025c30632e1482a8c0da4ee34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bitcask_dataset-0.3.1-py3-none-any.whl
| Download URL | bitcask_dataset-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8097ce75262e313a341e357258b91497ad1326c2e20579d982106f1a878cedc
|
|
BLAKE2b-256 checksum How to use checksums |
ee2d711dea1007114874af42cb96dd6ab600cb1e44a793697843ca31fd9300ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for bitcask-dataset 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.