y-crdt / ypy

Python bindings to y-crdt

Home Page:https://ypy.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retrieve YDoc from Y object

davidbrochart opened this issue · comments

Would it be possible to retrieve the YDoc a Y object is attached to? For instance through a ydoc property:

from y_py import YDoc

doc = YDoc()
text = doc.get_text('name')
assert text.ydoc is doc

I don't think it's possible at the current state. We didn't wanted to expose doc access from y-type to prevent people from throwing Doc instance away and use it instead.

There are some considerations around the fact that doc uses ref-count internally, which for avoiding memory leaks must never be using strong ref count (only weak ref count) within the objects that are stored inside of the document store itself.

Makes sense, thanks for the explanation!