Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Feature or enhancement
Currently when allocating a plain Python object, we allocate the object, and its values array.
This has a few downsides:
- We perform two allocations instead of one.
- An extra indirection is needed when accessing an attribute on the object
- If the
__dict__
is materialized we can no longer use specialized lookup.
We could fix three with an extra pointer in the object header, but that would waste more space.
We should append the values array directly after the object header, which fixes the above issues.
It adds some complexity, as we need to track ownership of the values so that they are freed exactly once, but may enable some simplifications as well. Overall, it would seem to make little difference to complexity.
Seefaster-cpython/ideas#72 for more discussion.
Linked PRs
- GH-115776: Embed the values array into the object, for "normal" Python objects. #116115
- GH-115776: Static object are immortal, so mark them as such. #117673
- GH-115776: Allow any fixed sized object to have inline values #123192
- GH-115776: Rename
Py_TPFLAGS_INLINE_VALUES
as_Py_TPFLAGS_INLINE_VALUES
#128635