Skip to main content

objstore-r

pip install uu-objstore-r → import objstore_r (Python ≥ 3.12, one abi3 wheel per platform).

One small object-store API over Google Cloud Storage, a local directory and memory, with the primitive that makes object storage usable as a database: generation preconditions (compare-and-swap).

import objstore_r

store = objstore_r.Store.gcs("my-bucket")        # Application Default Credentials
# store = objstore_r.Store.local("/var/data")    # same API on disk
# store = objstore_r.Store.memory()              # same API in memory (tests)

gen = store.put("state/HEAD", b"v1", create_only=True)
blob = store.get("state/HEAD")                   # Blob, zero-copy
view = memoryview(blob)                          # no copy of the downloaded bytes
store.put("state/HEAD", b"v2", if_generation=blob.generation)   # CAS
try:
    store.put("state/HEAD", b"v3", if_generation=gen)           # stale
except objstore_r.PreconditionFailedError:
    ...
  • Compare-and-swap everywhere. Every write returns the object's new generation; if_generation= and create_only= make writes conditional — on GCS (ifGenerationMatch), on disk (atomic across threads and processes), and in memory.
  • Zero-copy reads. Blob exports the downloaded buffer through the buffer protocol; pass a Blob back to put and it is not copied either.
  • Ranged and concurrent reads. get_range(key, start, end); get_many(keys) fetches concurrently.
  • Opt-in compression. put(key, data, content_encoding="gzip") stores an object compressed (on GCS as its contentEncoding); get decodes it once, in Rust, and the Blob is zero-copy from there. Meta.content_encoding reports it from head and list. A ranged read of an encoded object raises EncodedRangeError; decoding stops at max_inflated bytes (1 GiB by default, a keyword on every constructor) with TooLargeError.
  • Safe keys. /-separated segments of [A-Za-z0-9._-], validated before any I/O: no traversal, no hidden files, portable to every OS (InvalidKeyError otherwise).
  • Production GCS client. Resumable uploads above 8 MiB, ranged downloads, retries with jittered backoff on 408/429/5xx (never on conflicts), lost-response detection on conditional writes, response size limits, no redirects, TLS required except for a loopback emulator. Tokens are cached and never appear in errors or reprs.
  • Credentials. Application Default Credentials by default (gcloud user credentials or the metadata server on Cloud Run / GCE / GKE; service-account key files are deliberately unsupported), token= for a fixed bearer token, anonymous=True for fake-gcs-server.
  • Thread-safe. Every call releases the GIL; use a thread pool or asyncio.to_thread for concurrency.

Errors

All derive from ObjstoreError: NotFoundError (ranged read of a missing object; get/head return None instead), ConflictError, PreconditionFailedError, InvalidKeyError, UnavailableError, AuthError, TooLargeError, ProtocolError, EncodedRangeError (ranged read of an encoded object), UnsupportedEncodingError (an object stored with an encoding this build cannot decode). An unknown content_encoding= argument is a ValueError before any I/O.

Testing your code

Store.memory().inject_failure(after=n, lost_response=True) makes the n-th next operation fail — before applying, or after applying with the reply lost — to exercise retry paths.

Licence

AGPL-3.0-or-later, or a commercial licence — see the repository.

Metadata

Release files for uu-objstore-r 0.2.3

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

Source distribution (sdist)

Source distribution for uu-objstore-r 0.2.3
File Size Uploaded
uu_objstore_r-0.2.3.tar.gz 250.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for uu-objstore-r 0.2.3
File
uu_objstore_r-0.2.3-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details
uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details
uu_objstore_r-0.2.3-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
uu_objstore_r-0.2.3-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 10.6 MB

Release files / uu_objstore_r-0.2.3.tar.gz

Download URL uu_objstore_r-0.2.3.tar.gz
Size 250.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1daca64d6cd1680a684bd82c83d4c2fbdc2917d912dbaf9b7cc32004c829dcbd
BLAKE2b-256 checksum
How to use checksums
86526a8942f126d32a1bbebb20036e8649599ffb450df3edd532a4d7647d1cf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.3-cp312-abi3-win_amd64.whl

Download URL uu_objstore_r-0.2.3-cp312-abi3-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fbef5eb1bdcddecc320f07a68d2cc805c66dcff1b7219a23881eb723ebf5b82b
BLAKE2b-256 checksum
How to use checksums
838e575275bfa8c81bd74259720d844476b65b138f6507eb66e2ea59f13b5652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
58d40475d7674f939b07b6aca75bda58262c01f3abbf54cc86c9e7ddbe9628a8
BLAKE2b-256 checksum
How to use checksums
e50126a1d3f22f1051696eb73c15ea6885481d306583c6ab255d9b7a33ec6c8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL uu_objstore_r-0.2.3-cp312-abi3-manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
d5d88071a61e1f1a16300077b83547cf715ee5c1d92768276219bca0f2bfc520
BLAKE2b-256 checksum
How to use checksums
c1cbdc5dd7b9437657834a3ced1568407c8c4f8db90d88bfcc5a9a1a0eff9184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.3-cp312-abi3-macosx_11_0_arm64.whl

Download URL uu_objstore_r-0.2.3-cp312-abi3-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d954c43f54d6a6bd6d448fa87d1e183aa0450bceead917104337e743af6f6570
BLAKE2b-256 checksum
How to use checksums
bdbed1d39b22a8951ae7c123a0e0379afef1961e751a1ed305398f7bd2e1eb93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.3-cp312-abi3-macosx_10_12_x86_64.whl

Download URL uu_objstore_r-0.2.3-cp312-abi3-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1717177372406a62ce9f9dfb3c289da4d7dd86b7d8d8c1f8fd6f4c4db0f41225
BLAKE2b-256 checksum
How to use checksums
18f4dbc9c3b59eaef34c8b3d3f3b9f4f7f0d7775bd86124ad5a8e6b62627eec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.2.4

6 release files

This release

0.2.3 This release

6 release files

0.2.2

6 release files

0.2.0

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