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 loroVerified import paths — ran on the pinned version, not inferred.
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.
Update imports and instantiation from `from loro import Loro` to `from loro import LoroDoc`, and change `Loro()` to `LoroDoc()`.
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.
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.
Install the 'loro' library using pip: `pip install loro`
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`.
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.
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']`.