fast-langgraph vs orjson: 737× vs 2-5× for LangGraph checkpoint serialization
orjson accelerates Python's json module by 2-5× using Rust internally. fast-langgraph goes further: it bypasses Python object allocation entirely, parallelises across Rust threads, and adds batched SQLite writes — 737× faster for LangGraph checkpoints.
$ pip install fast-langgraph fast-langgraph is a Rust-backed drop-in for
orjson. Same API, faster hot paths.
Install: pip install fast-langgraph.
737× faster checkpoint serialization (0.1ms vs 73.5ms).
fast-langgraph vs orjson: the facts
737× faster checkpoint serialization (0.1ms vs 73.5ms).
2-5× faster than Python json.dumps (Rust-backed but still allocates Python objects).
Bypasses Python object allocation entirely (reads state directly from Python memory).
Still traverses the Python object tree; only the final byte serialization is in Rust.
Parallelises across Rust threads (no GIL contention).
Single-threaded; the GIL is held during the Python-side traversal.
Batched WAL writes to SQLite; no per-checkpoint fsync.
orjson is a serializer, not a storage layer — you still need your own SQLite integration.
Drop-in for LangGraph (auto-patch or RustSQLiteCheckpointer).
Drop-in for json.dumps — you wire it into LangGraph yourself.
MIT licensed.
MIT licensed.
Benchmarks
Reproduction instructions in the project README. Numbers measured on AMD Ryzen 9 7950X, 64GB DDR5, NVMe SSD, Python 3.12.
| Metric | fast-langgraph | orjson |
|---|---|---|
| Checkpoint serialization (50-msg state) | 0.1ms | ~15-30ms (estimated) |
| Checkpoint deserialization | 0.3ms | ~10-20ms (estimated) |
| Full state update (serialize + write + read) | 2.0ms | N/A (orjson does not include storage) |
When to use fast-langgraph
- You use LangGraph and checkpoint serialization is your bottleneck.
- You want the storage layer (batched WAL writes) as well as the serializer.
- You want a drop-in that patches LangGraph automatically.
When NOT to use fast-langgraph
- You only need a faster json.dumps for a non-LangGraph use case — use orjson directly.
- You want to keep your existing checkpointer and just swap the serializer — orjson + manual integration is lighter.
Frequently asked questions
Does fast-langgraph use orjson internally?
No. fast-langgraph uses Rust's serde + simd-json directly, bypassing Python object allocation entirely. orjson still traverses the Python object tree (in Python) before serializing to bytes (in Rust). fast-langgraph reads the state directly from Python's memory and writes JSON bytes without intermediate Python objects.
Can I use orjson and fast-langgraph together?
You can, but there's no benefit. fast-langgraph replaces the entire serialization + storage path; orjson would only be used if fast-langgraph falls back to the original Python implementation due to a version mismatch.
Why is fast-langgraph 737× faster when orjson is only 2-5× faster?
Three reasons: (1) fast-langgraph bypasses Python object allocation — orjson still allocates Python objects for every value in the state tree. (2) fast-langgraph parallelises across Rust threads — orjson is single-threaded. (3) fast-langgraph includes batched SQLite WAL writes — orjson is only a serializer, not a storage layer.