Skip to main content

pycobble

pycobble is the official high-performance Python binding for Cobble.

It requires CPython 3.11 or newer and ships a stable-ABI native wheel. Install it with:

pip install pycobble

Applications should import public names from pycobble, not pycobble._native.

Raw key/value API

import json
import pycobble

config = json.dumps({
    "volumes": [{
        "base_dir": "file:///tmp/example-cobble",
        "kinds": ["meta", "primary_data_priority_high", "snapshot"],
    }],
    "num_columns": 2,
    "total_buckets": 16,
})

with pycobble.SingleDb.open(config) as db:
    db.put(0, b"key", 0, b"value")
    row = db.get(0, b"key")
    assert bytes(row.column(0)) == b"value"

OwnedBytes implements Python's read-only buffer protocol, so memoryview can read a Rust-owned result without copying its payload:

value = row.column(0)
view = value.view()
assert view.readonly

For reusable caller-owned memory, get_column_into, next_batch_into, and the structured get_into, multi_get_into, next_batch_into, and priority-queue *into methods return a BufferResult. BufferStatus.BUFFER_TOO_SMALL reports the required size and leaves the output unchanged, so the same operation can be retried.

Structured API

db = pycobble.StructuredSingleDb.open(config)
schema = db.update_schema()
schema.add_list_column(1, pycobble.ListConfig(max_elements=8))
schema.commit()

batch = pycobble.StructuredWriteBatch()
batch.put_bytes(0, b"row", 0, b"payload")
batch.put_list(0, b"row", 1, [b"a", b"b"])
db.write(batch)

row = db.get(0, b"row")
assert bytes(row.bytes(0)) == b"payload"
assert bytes(row.list_element(1, 0)) == b"a"
db.close()

For snapshot reads, StructuredReader.open_current(config) follows the latest global snapshot on access and also supports explicit refresh(), while StructuredReader.open(config, id) stays fixed. StructuredReadOnlyDb.open(config, shard_snapshot_id, db_id) reads one shard snapshot. Both return the same typed rows and scans as the writable structured databases, including caller-owned CSRB buffer methods.

load_shard_snapshot_metadata(config, db_id, manifest_path) and load_global_snapshot_metadata(config, manifest_path) read only the snapshot metadata files. Each has a _file variant for a configuration path. A loaded GlobalSnapshot can be passed to Reader.open_from_global_snapshot or StructuredReader.open_from_global_snapshot to open a fixed view without reloading its global manifest. SingleDb and StructuredSingleDb return snapshot objects from list_snapshots() and IDs from list_snapshot_ids().

Multiprocessing

Snapshot metadata, scan plans and splits, options, write batches, and detached result values support standard pickle, including spawn workers. For example, a worker can return a ShardSnapshot to the parent coordinator; the parent can send a ScanPlan or ScanSplit back to workers and receive detached batches. Use spawn rather than inheriting native storage runtimes with fork.

Pickles carry values and metadata, not data files or a snapshot-retention lease. Workers still need access to the same configured storage, and the caller must retain snapshots while work is in flight. Database, reader, coordinator, cursor, priority-queue, pending-snapshot, and schema-builder handles are not transferable. Unpickle only trusted data.

API surface

The binding includes:

  • raw SingleDb and sharded Db CRUD, batches, multi-get, scans, schemas, snapshots, recovery, metrics, lifecycle operations, and rescaling;
  • Reader, ReadOnlyDb, DbCoordinator, and typed distributed scan plans;
  • structured BYTES/LIST rows, batches, scans, schema evolution, snapshots, recovery, rescaling, snapshot readers, typed distributed scans, and priority queues;
  • typed errors and complete .pyi declarations.

All database calls are synchronous. Blocking storage work releases the Python GIL where the underlying cursor or borrowed Python buffer does not require the originating thread. Database handles and cursors should be externally synchronized rather than used concurrently from multiple Python threads.

Build from source

python3.11 -m venv .venv
. .venv/bin/activate
pip install maturin pytest
maturin develop --manifest-path cobble-binding/cobble-python/Cargo.toml
pytest cobble-binding/cobble-python/tests

Publishing to PyPI

Publishing a GitHub Release runs python-package.yml: it builds and smoke-tests the platform wheels, builds the source distribution, then uploads them to PyPI as pycobble and attaches them to the GitHub Release. The release tag must match the workspace version (for example, v0.5.0). Manual workflow runs only build artifacts and do not publish. Pre-release GitHub Releases also trigger publishing; use a pre-release package version and matching tag for those.

One-time setup (no repository secrets or custom variables are required):

  1. Create a GitHub Actions environment named pypi. Optionally require approval and restrict it to release tags.
  2. In PyPI, configure a Trusted Publisher for pycobble:
    • Owner: cobble-project
    • Repository: cobble
    • Workflow: python-package.yml
    • Environment: pypi
  3. If the PyPI project does not exist yet, use PyPI's pending publisher setup with project name pycobble before the first release.

GitHub supplies the short-lived publishing credentials automatically. Re-running the PyPI job skips files already uploaded; changed packages need a new version. See PyPI Trusted Publishers for setup instructions.

Release files for pycobble 0.5.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 pycobble 0.5.0
File Size Uploaded
pycobble-0.5.0.tar.gz 777.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pycobble 0.5.0
File
pycobble-0.5.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pycobble-0.5.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
pycobble-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
pycobble-0.5.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pycobble-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 47.1 MB

Release files / pycobble-0.5.0.tar.gz

Download URL pycobble-0.5.0.tar.gz
Size 777.4 kB
Tags Source
SHA-256 checksum
How to use checksums
447e53cddce2448200d52007ddecdad03db4f97fe25a1f094b5bc96b7faf47a8
BLAKE2b-256 checksum
How to use checksums
28e8fd1a27e888bbc1afea7eb87708c9137dbc613175cc016f84e0a0752f1205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pycobble-0.5.0-cp311-abi3-win_amd64.whl

Download URL pycobble-0.5.0-cp311-abi3-win_amd64.whl
Size 9.6 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
495b46196837fb136b4520a40885deb8c0b973ac2a2d4e10beb89fd2240a88a7
BLAKE2b-256 checksum
How to use checksums
7d7abe5aafaae414416b95600f77e1d47c3367bf2c75acf21f0213fb8b47e260
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pycobble-0.5.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL pycobble-0.5.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 9.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
db1bc3668b779d3433da8ff2598adcbb3ad2792792d8ef37ed886de99fcdcf44
BLAKE2b-256 checksum
How to use checksums
d81beb9966d66836427b4eaac3d3afbb339226ec92ff6ecd801e472ad79a5cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pycobble-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL pycobble-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 9.3 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4fdb77245c2a431a9d89e9fb78542a81146ccdd68a7da56f937803e0b3455fb3
BLAKE2b-256 checksum
How to use checksums
ddc52df0f0092e94e78b0a48823c95d4c38db524211b3edd65441289fb8ac5e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pycobble-0.5.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL pycobble-0.5.0-cp311-abi3-macosx_11_0_arm64.whl
Size 8.3 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fff30493482ee2dd729dafc4842281f431cc5a13007983cdd4349234a7aa79f4
BLAKE2b-256 checksum
How to use checksums
03cf1ba785b3747653ec91b81aeafaba6d9b65cb35f7a41039f2396de3e1c586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pycobble-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pycobble-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 9.4 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0ce715bc6d020b739e6682dd94f5cd0862c9a5fa24a809a6e61ba892f536c259
BLAKE2b-256 checksum
How to use checksums
69e38f625fdcd2858105079e27ac48070968f55e2991ce162a609a9e836a053a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

6 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