Improve memory usage of storing record values
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).