Message 58290

Author
ced
Date
2020-05-26.17:23:45
Message id
58290

Content

For now, the values of a record are set as dictionaries in the local and transactional caches.
But dictionaries are memory expensive:

>>> sys.getsizeof({})
248
>>> sys.getsizeof([])
72
>>> sys.getsizeof(object())
16

But a class with __slots__ have a size of 16 + 8 per slot (64 without slots but it contains a __dict__ of 248).

So we see that we can store 29 ((248 - 16) / 8) slots for the same memory size as an empty dict.

So the proposal is to create a record class for each model that has a slot for each field and some methods similar to dict like get, keys, items, update etc. Those class should be used in local and transaction caches and in _values and _init_values.
The side effect is that we also receive an automatic check that prevents to fill the cache record with unknown fields (thanks to the slots).
History
Date User Action Args
2020-05-26 17:23:46cedsetmessageid: <1590506626.54.0.874007409086.issue9369@tryton.org>
2020-05-26 17:23:46cedlinkissue9369 messages
2020-05-26 17:23:45cedcreate

Showing 10 items. Show all history (warning: this could be VERY long)