Registry / data / loro
library1.13.2pypypi✓ verified 23d ago

Loro provides high-performance Python bindings for the Loro Conflict-free Replicated Data Type (CRDT) library. It enables real-time collaboration and local-first software development by offering conflict-free data synchronization across distributed environments. The library supports various rich data types like Text, List, Map, and Tree. Currently at version 1.10.3, it maintains an active development and release schedule.

pip install loro
INSTALL
IMPORT
SIG · LORO
L
loro
datapythonv1.13.2
Install
1.9s avg
Import
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.13.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LoroDoc
from loro import LoroDoc

Initialize a LoroDoc, interact with CRDT data types like Text and Map, subscribe to changes, commit operations, and export/import document snapshots for persistence or synchronization.

from loro import LoroDoc # Create a new document doc = LoroDoc() # Get a text container (creates it if it doesn't exist) text = doc.get_text("my-shared-text") # Insert text at a specific position text.insert(0, "Hello, Loro!") # You can also use other CRDT types like Map or List map_container = doc.get_map("my-shared-map") map_container["key"] = "value" # To observe changes, subscribe to the document def on_change(event): print(f"Document changed: {event}") # Store the subscription reference to prevent garbage collection if running in an interactive session sub = doc.subscribe_root(on_change) # Commit changes to generate an update (important for sharing/persisting) doc.commit() # To get the current state as a snapshot snapshot = doc.export(mode="snapshot") print(f"Snapshot size: {len(snapshot)} bytes") # To load a document from a snapshot new_doc = LoroDoc() new_doc.import_from(snapshot) print(f"Loaded text: {new_doc.get_text('my-shared-text').get_value()}")
Debug
Known issues
breakingThe `Loro` class was renamed to `LoroDoc` in Loro v1.0. Code using `Loro()` as the entry point will break.
fix
Update imports and instantiation from `from loro import Loro` to `from loro import LoroDoc`, and change `Loro()` to `LoroDoc()`.
affects: >=1.0.0
breakingLoro v1.9.0 and later removed legacy v0.x encoding support. Documents created with v0.x must be migrated via an intermediate Loro release (version <=1.8.x) before upgrading to v1.9.0 or newer.
fix
If you have documents saved with Loro v0.x, first upgrade to a version between v1.0.0 and v1.8.x, load and re-save your documents, then upgrade to the latest Loro version.
affects: >=1.9.0
gotchaWhen defining Python functions that might interact with Loro's mutable data structures (e.g., passing a `LoroList` as a default argument to be modified), avoid using mutable objects as default argument values. This can lead to unexpected state sharing across function calls.
fix
Instead of `def my_func(arg=[]):`, use `def my_func(arg=None): if arg is None: arg = []`. This ensures a fresh mutable object is used for each call unless explicitly provided.
affects: All Python versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'loro'
The 'loro' package is not installed in your Python environment or the Python interpreter cannot find it in its search path. This typically happens when the library has not been installed via pip, or it was installed in a different environment than the one currently active.
fix
Install the 'loro' library using pip: `pip install loro`
ImportError: cannot import name 'Text' from 'loro'
You are trying to import a specific class or submodule (like `Text`, `List`, `Map`, or `Tree`) directly from the top-level `loro` package, but it might be nested within a submodule or not directly exposed at the top level.
fix
Check the `loro` documentation for the correct import path for the specific class you need. For example, it might be `from loro.text import Text` or `from loro.list import List`.
AttributeError: 'LoroDoc' object has no attribute 'apply_patch'
You are attempting to call a method or access an attribute on a `loro` object (e.g., `LoroDoc`, `LoroText`, `LoroMap`) that does not exist or is misspelled. This often occurs when misremembering API methods or attempting operations not supported by that specific `loro` data type.
fix
Consult the `loro` library's official documentation for the correct method names and available attributes for the object you are using. Ensure your code aligns with the library's API for the specific `loro` data structure.
TypeError: 'LoroMap' object is not subscriptable
You are trying to access elements of a `LoroMap` object using square bracket notation (e.g., `my_map['key']`), similar to a Python dictionary, when the `LoroMap` object might require specific methods (like `get()` or `set()`) for key-based access or modifications. This often occurs because Loro's CRDT types, while resembling Python natives, have their own API for managing state.
fix
Use the appropriate methods provided by the `LoroMap` API for interacting with its elements. For example, use `my_map.get('key')` to retrieve a value or `my_map.set('key', value)` to set a value, rather than `my_map['key']`.
Upgrade
Version history
1.13.2latest on PyPI · released Jul 21, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.8 or newer for the bindings.
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources