I have the snippet below where I want to create objects with a nested structure so that when I append values to obj1._data then _datatwo is updated. Idea is that _datatwo is a growing OrderedDict with each instances of DataOne object.
from collections import OrderedDict, deque
class DataOne:
def __init__(self):
self._data = deque()
self._dataqueue = OrderedDict()
self._dataqueue["key"] = self._data
@property
def get_data(self):
return self._data
class DataTwo:
_datatwo = OrderedDict()
def __init__(self):
pass
@classmethod
def append_value(cls, dataone: DataOne):
cls._datatwo["key"] = dataone
obj1 = DataOne()
obj2 = DataTwo()
for i in range(10):
obj1._data.append(i)
DataTwo.append_value(obj1)
print(DataTwo._datatwo['key'].get_data)
However this schema doesn't work with big data (10000 entries are enough). deque returns correct values inside the loop but when I call from outside deque returns always empty.