[IMP] core: do not assign default values on fields

This keeps field.__dict__ as small as possible.

On a registry with 296 modules, this saves 40 kilobytes of memory,
which is about 0.35% of the registry's memory footprint.
This commit is contained in:
Raphael Collet
2021-05-10 14:29:43 +00:00
parent 1abe965b59
commit 5ae684f79d
+3 -1
View File
@@ -419,7 +419,9 @@ class Field(MetaField('DummyField', (object,), {})):
if extra_keys:
attrs['_extra_keys'] = extra_keys
self.__dict__.update(attrs)
for key, val in attrs.items():
if getattr(self, key, Default) != val:
setattr(self, key, val)
# prefetch only stored, column, non-manual and non-deprecated fields
if not (self.store and self.column_type) or self.manual or self.deprecated: