Closed
Description
Accessing the __dict__
attribute of an object causes the dictionary to be materialized.
This has a negative impact on performance.
We should provide means to access the __dict__
without forcing materialization, which can be used in copy, pickle and any third party code that chooses to.
I propose two new methods on object
:
__dict_copy__(self)
, which will be equivalent toself.__dict__.copy()
, but without materializing the dictionary of objects with virtual dictionaries.__dict_update__(self, arg)
, which will be equivalent toself.__dict__.update(arg)
, but without materializing the dictionary of objects with virtual dictionaries.
Linked PRs
- GH-106485: "Un-materialize"
__dict__
s inLOAD_ATTR_WITH_HINT
#106496 - GH-106485: Dematerialize instance dictionaries when possible #106539
- GH-106485: Handle dict subclasses correctly when dematerializing
__dict__
#107837 - GH-106485: Create object's dict-values instead of creating __dict__, when we can. #107843