zodb-json-codec#
Fast pickle-to-JSON transcoder for ZODB, implemented in Rust via PyO3.
Converts ZODB pickle records into human-readable, JSONB-queryable JSON while staying round-trip safe. Designed as the codec layer for a PostgreSQL JSONB storage backend.
Key capabilities:
Round-trip safe: encode to JSON and back yields a pickle that unpickles to an equal object (the bytes differ: memo puts are dropped and the header is rewritten, see JSON format)
Human-readable JSON with compact type markers (
@dt,@ref,@t, …)JSONB-queryable output for PostgreSQL
Faster than CPython’s C pickle extension on most operations
GIL released during Rust phases for multi-threaded Python
Direct JSON string path for zero-copy PostgreSQL storage
BTree flattening for all BTrees package types
Escape hatch (
@pkl) ensures any pickle data roundtrips safely
Requirements: Python 3.12+, Rust toolchain and a C compiler (for building from source)
Documentation#
Learning-oriented – Step-by-step lessons to build skills.
Start here if you are new to zodb-json-codec.
Goal-oriented – Solutions to specific problems.
Use these when you need to accomplish something.
Information-oriented – Technical specifications and API details.
Consult when you need detailed information.
Understanding-oriented – Architecture, design decisions, and optimization history.
Read to deepen your understanding of how it works.