Use tagged pointers for more efficient integer operations.
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
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 https://github.com/python/cpython/issues/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-157353
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先阅读 issue #132508、关联的 pull request #157353 以及引用的 Discourse 讨论,以了解提议的带标记指针表示和当前工作。该 issue 没有指定文件、测试或范围明确的实现任务;完成它需要定义并验证更广泛的解释器和 VM 设计。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100