Inline values array into the object #115776
Labels
3.13
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
type-feature
A feature request or enhancement
Feature or enhancement
Currently when allocating a plain Python object, we allocate the object, and its values array.
This has a few downsides:
__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.
See faster-cpython/ideas#72 for more discussion.
Linked PRs
The text was updated successfully, but these errors were encountered: