python / python/cpython

Specialized subscript guards should require non-negative compact ints

未關閉
#153,486 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core performance type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

The specialized int subscript fast paths currently assume a non-negative compact int, but that precondition is not expressed directly in the guard.

Make the guard explicit for the affected cases:

  • list[i]
  • tuple[i]
  • str[i]
  • list[i] = value

This aligns the guard with the existing specialization contract and removes redundant checks from the specialized bodies, without changing the fallback path for negative indices.

Linked PRs
  • gh-153487
  • gh-153523

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先定位用於 list[i]、tuple[i]、str[i] 和 list[i] = value 的專用 int 下標快速路徑。檢查它們的 guard 如何表達 compact-int 前置條件,以及負索引如何到達 fallback path。完成的標準是:guard 要求非負 compact int,移除 specialized body 中多餘的檢查,並且負索引的行為保持不變。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
compilers, performance
Issue 類型
重構
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。