loro-py
Python bindings for the Loro CRDT engine for local-first, collaborative data.
Repository Health
Technical Analysis
Loro-py exposes the high-performance Rust Loro CRDT library to Python, letting applications build local-first and collaborative features without a central server. It provides conflict-free replicated data types including Text, List, Map, Tree, Movable List, and Counter behind a Pythonic API.
Backed by Loro’s Rust core through PyO3, it handles merging concurrent edits, versioning, and change subscriptions, making it a foundation for collaborative editors, offline-first apps, and distributed state synchronization in Python.
What You Get
- A
LoroDocdocument type with Text, List, Map, Tree, Movable List, and Counter containers - Automatic conflict-free merging of concurrent edits across replicas
- A Rust-powered core exposed through a Pythonic PyO3 API
- Change subscriptions for reacting to document updates
- Type stubs (loro.pyi) for editor autocompletion and static checking
Common Use Cases
- Building collaborative text or structured-document editors in Python
- Adding offline-first, syncable state to desktop or backend applications
- Synchronizing shared data structures across distributed peers
- Experimenting with CRDTs from Python without writing Rust
Under The Hood
Architecture - Loro-py is a thin binding layer over the Rust Loro CRDT engine. The src/ directory contains Rust code compiled into a native CPython extension via PyO3, exposing a LoroDoc object whose container accessors (get_text, get_map, get_tree, etc.) return CRDT handles; edits are recorded as operations, committed with doc.commit(), and merged deterministically across replicas, with a subscription mechanism for change notifications. Tech Stack - Rust core built with maturin (>=1.8) and PyO3 with the extension-module feature, packaged for CPython and PyPy on Python 3.8+. A loro.pyi stub provides Python-side type information, and Cargo manages the Rust dependency graph. Code Quality - The repository includes a tests/ directory and development requirements, and correctness largely rests on the well-tested upstream Loro engine that these bindings wrap; the binding project itself is small and comparatively early-stage with limited community activity. API Design - The Python API mirrors Loro’s model closely and reads naturally - create a LoroDoc, fetch a typed container, mutate it, and commit - keeping boilerplate low, though users must understand CRDT concepts and the commit/subscription lifecycle, which raises the learning curve somewhat.