Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline values array into the object #115776

Closed
Tracked by #654
markshannon opened this issue Feb 21, 2024 · 1 comment
Closed
Tracked by #654

Inline values array into the object #115776

markshannon opened this issue Feb 21, 2024 · 1 comment
Assignees
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

Comments

@markshannon
Copy link
Member

markshannon commented Feb 21, 2024

Feature or enhancement

Currently when allocating a plain Python object, we allocate the object, and its values array.
This has a few downsides:

  1. We perform two allocations instead of one.
  2. An extra indirection is needed when accessing an attribute on the object
  3. 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.

See faster-cpython/ideas#72 for more discussion.

Linked PRs

@markshannon markshannon added type-feature A feature request or enhancement performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.13 new features, bugs and security fixes labels Feb 21, 2024
@markshannon markshannon self-assigned this Feb 21, 2024
@encukou
Copy link
Member

encukou commented Apr 11, 2024

This change introduced a regression, see #117750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants