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 maintaining full roundtrip fidelity. Designed as the codec layer for a PostgreSQL JSONB storage backend.

Key capabilities:

  • Full roundtrip fidelity: encode to JSON and back produces identical pickle bytes

  • Human-readable JSON with compact type markers (@dt, @ref, @kv, …)

  • 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.10+, Rust toolchain (for building from source)

Documentation

Tutorials

Learning-oriented – Step-by-step lessons to build skills.

Start here if you are new to zodb-json-codec.

Tutorials
How-To Guides

Goal-oriented – Solutions to specific problems.

Use these when you need to accomplish something.

How-To Guides
Reference

Information-oriented – Technical specifications and API details.

Consult when you need detailed information.

Reference
Explanation

Understanding-oriented – Architecture, design decisions, and optimization history.

Read to deepen your understanding of how it works.

Explanation

Quick Start

  1. Install zodb-json-codec

  2. Encode and decode your first pickle

  3. Work with ZODB records