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 — Use tagged pointers for more efficient integer operations. · Issue #132509 · python/cpython

Use tagged pointers for more efficient integer operations. #132509

New issue
Copy link
New issue
Copy link
Open
Open
Use tagged pointers for more efficient integer operations.#132509
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement

Description

@markshannon
markshannon
opened on Apr 14, 2025
Issue body actions

Feature or enhancement

Proposal:

From the discourse discussion:

Integers are ubiquitous, both in Python code and the virtual machine.
However our representation of integers is somewhat clunky and inefficient.

There is an old technique for handling ints efficiently in dynamic language VMs, called tagged pointers.
A normal object pointer always has its low bits set to zero, as objects are 8 or 16 byte aligned in memory.
We can use those low bits as “tags” to denote the meaning of the high bits.
Historically, the low bit has been set to zero to indicate that the high bits are a pointer, and to 1 to indicate that the high bits are an integer.

We already use another tagging scheme within the interpreter and in the frame stack, the tag indicating whether the reference is borrowed.

I expect to start small with this, initially just fixing #132508 then improving the performance of iteration over lists and tuples.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/using-tagged-pointers-to-support-efficient-integer-operations/87950

Linked PRs

  • gh-132509: Speed up bytes iteration in FOR_ITER_VIRTUAL #157353
Reacted by Djemmal Islam and Wulian233

Activity

  1. markshannon
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 14, 2025
  2. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    performancePerformance or resource usagePerformance or resource usage
    on Apr 14, 2025
  3. BHUVANSH855
    added a commit that references this issue on Sep 19, 2026

    pythongh-132509: Speed up bytes iteration in FOR_ITER_VIRTUAL

    bd5d715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement

    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.