Repository navigation
Reduce the size of plain Python objects from 8 to 6 machine words. #95245
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Description
Activity
- addedperformancePerformance or resource usagePerformance or resource usage
on Jul 25, 2022 - changed the title
[-]Reduce the size of plain objects from 8 to 6 machines words.[/-][+]Reduce the size of plain Python objects from 8 to 6 machine words.[/+]on Jul 25, 2022 - added a commit that references this issue
on Aug 1, 2022 Is there anything left to do here?
- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Sep 10, 2022 Nothing more to do.
Re-opening per discussion in #135755.
Reacted by Sergey Miryanov- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Jun 24, 2025 There's no documentation about
Py_TPFLAGS_PREHEADER. What's it for? How should users use it?Reacted by Peter Bierma- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Jun 24, 2025 As I understand it, users are not supposed to use this flag. It is only used for internal purposes.
- added a commit that references this issue
on Aug 25, 2025
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Currently a plain Python object has the following fields:
The
WASTEDfield is present because, due to alignment, we must allocate a multiple of 2 words.We can reduce this to 6 by merging the values and __dict__ pointers into one (only one can be valid at any time),
and then moving the __weakrefs__ field into the empty space.
See faster-cpython/ideas#125 for full discussion
Linked PRs