-
Notifications
You must be signed in to change notification settings - Fork 294
Open
Description
In pydantic v1, replacing each instantiated object's __dict__
with a dict of validated values used to broke
PEP 412 (use of shared dictionary keys), which probably explains a part of the excessive memory usage of V1 when a lot of objects of same type were created.
This may be a concern still in v2, if I read rows like this correctly:
force_setattr(py, model, intern!(py, DUNDER_DICT), validated_dict)?;
I have no adequate rust skills to test this, but it could be beneficial to study how shared keys affect memory consumption of objects validated by pydantic, and could updating __dict__
instead of replacing result in a smaller memory footprint.
More about shared keys, I hope that this is still relevant:
Metadata
Metadata
Assignees
Labels
No labels