Extend and improve `LOAD_COMMON_CONSTANT`
未关闭
还没有人认领这个 Issue。
interpreter-core
performance
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Currently LOAD_COMMON_CONSTANT only loads 7 not-so-common constants and does so fairly inefficiently.
It could be improved in two ways:
- Add some more constants, especially
None, but also"",True,Falseand-1 Make the constants that it does load both statically allocated and immortal to avoid the pointer chasing and incref operation. Onlyanyandallwould need changing.
After some consideration, I think it best to leave the common constants table per interpreter, and not statically allocate them.
- The changes to
anyandallmay be breaking. - We also need to handle
AssertionErrorandNotImplementedErrorwill be tricky to make static
They should all be immortal though, and stored as _PyStackRefs not PyObject *s.
Linked PRs
- gh-148971
- gh-149625
- gh-149688
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 LOAD_COMMON_CONSTANT 入口点开始,检查每个解释器的公共常量表如何存储和返回值。在更改设计之前查看相关 PR,尤其关注 _PyStackRef、永生性以及 any/all 方面的考虑。完成的标准是:已达成共识的公共常量(包括 None、空字符串、True、False 和 -1)都能得到处理,且不采用已被否决的静态分配方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100