y-py is a high-performance Python binding for Y-CRDT, a distributed data type library built in Rust. It enables seamless real-time synchronization of state between processes and cross-domain communication with other Y-CRDT bindings like Y-Wasm. The project is currently experimental, with API changes expected before a 1.0 stable release. The current stable version is 0.6.2.
pip install y-pyVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create a YDoc, modify its content within a transaction, and synchronize changes between two document instances.
Refer to the latest official documentation and release notes for API changes when upgrading.
Upgrade to `y-py` 0.6.2 or later for Python 3.12 compatibility.
Always wrap modifications to shared types within a `with doc.begin_transaction() as txn:` block.
Update method calls to `Y.apply_update()` and verify other API changes against the latest documentation.
Install the Rust toolchain using `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` and ensure `cargo` is added to your system's PATH.
Access the string content using `str(y_text_obj)` or `y_text_obj.to_json()`.
Wrap all modification operations inside a `with ydoc.begin_transaction() as txn:` block, passing the `txn` object as the first argument to the modification method (e.g., `y_text.insert(txn, 0, 'hello')`).
Ensure Rust and Cargo are installed and up-to-date (`rustup update`), and check platform-specific requirements. Sometimes `pip install maturin` can help before `pip install y-py`.
Change the import statement from `import ypy` to `import y_py`.
No dependency data recorded yet.