Remove `DELETE_FAST` bytecode instruction
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
DELETE_FAST has two uses:
delete varwherevaris a local variable- Cleaning up at the end of a named exception block.
A local variable can be deleted with the sequence PUSH_NULL; STORE_FAST var.
Deleting a local variable
Instead of DELETE_FAST n we can emit LOAD_FAST n; POP_TOP n; PUSH_NULL; STORE_FAST n which the bytecode optimizer will reduce to PUSH_NULL; STORE_FAST n in most cases.
Cleaning up at the end of a named exception block.
We currently emit the sequence: LOAD_CONST None; STORE_FAST n; DELETE_FAST n
which can be replaced with PUSH_NULL; STORE_FAST n
This case is far more common than explicitly deleting a local variable, so we can reduce code size as well as freeing up an opcode.
See https://github.com/faster-cpython/ideas/issues/490
Linked PRs
- gh-145983
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先跟踪为局部变量删除和具名异常清理发出 DELETE_FAST 的编译器入口点。将它们的字节码输出与提议的 PUSH_NULL; STORE_FAST 序列进行比较,然后验证不再发出 DELETE_FAST,并且现有的字节码测试仍然通过;该 issue 引用了关联的 PR gh-145983。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100