implemented the deletion of unnecesarry details in not chosen objects, for the sake of memory efficiency in the history

This commit is contained in:
Hellow2
2023-06-16 10:43:35 +02:00
parent b20d7fcc76
commit f471c6a72b
4 changed files with 18 additions and 1 deletions

View File

@@ -158,3 +158,6 @@ class Collection:
@property
def empty(self) -> bool:
return len(self._data) == 0
def clear(self):
self.__init__(element_type=self.element_type)

View File

@@ -95,6 +95,10 @@ class DatabaseObject:
if override or getattr(self, simple_attribute) == default_value:
setattr(self, simple_attribute, getattr(other, simple_attribute))
def strip_details(self):
for collection in type(self).DOWNWARDS_COLLECTION_ATTRIBUTES:
getattr(self, collection).clear()
@property
def metadata(self) -> Metadata:
return Metadata()