Skip to content

Reduce the size of plain Python objects from 8 to 6 machine words. #95245

Open
@markshannon

Description

@markshannon

Currently a plain Python object has the following fields:

  • values
  • (managed) __dict__
  • GC 1
  • GC 2
  • refcount
  • __class__
  • __weakrefs__
  • WASTED

The WASTED field 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.

  • __weakrefs__
  • values or __dict__
  • GC 1
  • GC 2
  • refcount
  • __class__

See faster-cpython/ideas#125 for full discussion

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions