{"id":4330,"library":"y-py","title":"y-py: Python bindings for Y-CRDT","description":"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.","status":"active","version":"0.6.2","language":"en","source_language":"en","source_url":"https://github.com/y-crdt/ypy","tags":["CRDT","real-time","collaboration","data synchronization","Rust binding"],"install":[{"cmd":"pip install y-py","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"The common and recommended pattern is to import the library as 'Y' and access classes/functions through it.","wrong":"from y_py import YDoc","symbol":"YDoc","correct":"import y_py as Y; doc = Y.YDoc()"}],"quickstart":{"code":"import y_py as Y\n\nd1 = Y.YDoc()\ntext = d1.get_text('test')\n\nwith d1.begin_transaction() as txn:\n    text.extend(txn, \"hello world!\")\n\nd2 = Y.YDoc()\nstate_vector = Y.encode_state_vector(d2)\ndiff = Y.encode_state_as_update(d1, state_vector)\nY.apply_update(d2, diff)\n\nvalue = str(d2.get_text('test'))\nassert value == \"hello world!\"\nprint(f\"Synchronized text: {value}\")","lang":"python","description":"This example demonstrates how to create a YDoc, modify its content within a transaction, and synchronize changes between two document instances."},"warnings":[{"fix":"Refer to the latest official documentation and release notes for API changes when upgrading.","message":"The `y-py` library is currently experimental, and its API is subject to change without strict backward compatibility guarantees before a 1.0 stable release. Users should anticipate potential breaking changes with minor version updates.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Upgrade to `y-py` 0.6.2 or later for Python 3.12 compatibility.","message":"Initial support for Python 3.12 was introduced in `y-py` version 0.6.2. Users running earlier versions of `y-py` with Python 3.12 may encounter compatibility issues.","severity":"gotcha","affected_versions":"<0.6.2"},{"fix":"Always wrap modifications to shared types within a `with doc.begin_transaction() as txn:` block.","message":"All modifications to `YDoc` shared types (e.g., `YText`, `YMap`, `YArray`) must occur within a transaction context initiated by `doc.begin_transaction()`. Attempting to modify shared types outside a transaction or initiating multiple concurrent transactions on the same document will raise an exception.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update method calls to `Y.apply_update()` and verify other API changes against the latest documentation.","message":"Prior to version 0.5.5, some update application methods might have had different names (e.g., `applyV1`). The current public API uses `Y.apply_update()` for applying document updates. Code using older method names will break with modern `y-py` versions.","severity":"breaking","affected_versions":"<0.5.5"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}