GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reduce the size of plain Python objects from 8 to 6 machine words. · Issue #95245 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Reduce the size of plain Python objects from 8 to 6 machine words.#95245
Copy link
Assignees
markshannon
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Description

@markshannon
markshannon
opened on Jul 25, 2022
Issue body actions

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

  • gh-95245: Document Py_TPFLAGS_PREHEADER #135861
Reacted by Christian Heimes, Ken Jin, Erlend E. Aasland and Donghee Na

Activity

  1. markshannon
    added
    performancePerformance or resource usagePerformance or resource usage
    on Jul 25, 2022
  2. markshannon
    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
  3. markshannon
    moved this to Todo in Fancy CPython Boardon Jul 25, 2022
  4. markshannon
    added this to Fancy CPython Boardon Jul 25, 2022
  5. mdboom
    moved this from Todo to In Progress in Fancy CPython Boardon Jul 26, 2022
  6. mdboom
    assigned
    markshannon
    on Jul 26, 2022
  7. markshannon
    added a commit that references this issue on Aug 1, 2022

    GH-95245: Store object values and dict pointers in single tagged poin…

    de388c0
  8. markshannon
    moved this from In Progress to In Review in Fancy CPython Boardon Aug 15, 2022
  9. markshannon
    added a commit that references this issue on Aug 16, 2022

    GH-95245: Move weakreflist into the pre-header. (GH-95996)

    5a8c158
  10. markshannon
    moved this from In Review to Done in Fancy CPython Boardon Aug 22, 2022
  11. markshannon
    added a commit that references this issue on Aug 30, 2022

    GH-95245: Document use of `MANAGED` flags instead of offsets. (GH-96044)

    0f733ff
  12. iritkatriel commented on Sep 10, 2022

    @iritkatriel
    iritkatriel
    on Sep 10, 2022
    Member
    More actions

    Is there anything left to do here?

  13. iritkatriel
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Sep 10, 2022
  14. markshannon commented on Sep 12, 2022

    @markshannon
    markshannon
    on Sep 12, 2022
    MemberAuthor
    More actions

    Nothing more to do.

  15. markshannon
    closed this as completedon Sep 12, 2022
  16. AA-Turner commented on Jun 24, 2025

    @AA-Turner
    AA-Turner
    on Jun 24, 2025
    Member
    More actions

    Re-opening per discussion in #135755.

    Reacted by Sergey Miryanov
  17. AA-Turner
    reopened this on Jun 24, 2025
  18. ZeroIntensity
    removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Jun 24, 2025
  19. encukou commented on Jun 24, 2025

    @encukou
    encukou
    on Jun 24, 2025
    Member
    More actions

    There's no documentation about Py_TPFLAGS_PREHEADER. What's it for? How should users use it?

    Reacted by Peter Bierma
  20. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Jun 24, 2025
  21. sergey-miryanov commented on Jun 24, 2025

    @sergey-miryanov
    sergey-miryanov
    on Jun 24, 2025
    Contributor
    More actions

    As I understand it, users are not supposed to use this flag. It is only used for internal purposes.

  22. encukou
    added a commit that references this issue on Aug 25, 2025

    gh-95245: Document Py_TPFLAGS_PREHEADER (GH-135861)

    5baa7a0
  23. encukou
    closed this as completedon Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @markshannon
    markshannon

Labels

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.