Minor change to LOAD_ATTR Opcode in 3.13 not documented
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Documentation
The order that items are pushed to the stack by LOAD_ATTR changed in 3.13, but this is not mentioned in the dis module documentation for the LOAD_ATTR Opcode.
Further Details
For the LOAD_ATTR Opcode, the following change from 3.12 is documented
Changed in version 3.12: If the low bit of namei is set, then a NULL or self is pushed to the stack before the attribute or unbound method respectively.
And this can be seen in frameobject.c: https://github.com/python/cpython/blob/3.12/Objects/frameobject.c#L422 where NULL is pushed before Object.
However, in 3.13 this has changed, presumably due to changes to the CALL Opcode;
Changed in version 3.13: The callable now always appears at the same position on the stack.
And for LOAD_ATTR the NULL is now pushed to the stack after the attribute or unbound method.
This ordering change can be seen in frameobject.c for 3.13: https://github.com/python/cpython/blob/3.13/Objects/frameobject.c#L1280 where Object is now pushed before NULL.
Suggested Resolution
My suggestion would be adding something like this to the LOAD_ATTR documentation;
Changed in version 3.13: When the low bit of namei is set, NULL or self is pushed to the stack after the attribute or unbound method respectively.
Linked PRs
- gh-138631
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Python 3.13 dis 模組文件中的 LOAD_ATTR 項目開始,將其措辭與 issue 中連結的 3.12 和 3.13 frameobject.c 位置進行比較。在進行變更前檢查連結的 PR gh-138631;當 3.13 的堆疊順序變更被準確記錄後,文件工作就完成了。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100