You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specialized subscript guards should require non-negative compact ints #153486
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.
BINARY_OP_SUBSCR_LIST_INT doesn't require that the index is non-negative, so this will slowdown l[-1]
Negative indices are quite common, especially -1.
Perhaps, it would make more sense to handle negative indices for all these cases, like BINARY_OP_SUBSCR_LIST_INT already does:
Activity
pythongh-153486: Add NEWS entry
markshannon commentedon Jul 10, 2026
BINARY_OP_SUBSCR_LIST_INTdoesn't require that the index is non-negative, so this will slowdownl[-1]Negative indices are quite common, especially -1.
Perhaps, it would make more sense to handle negative indices for all these cases, like
BINARY_OP_SUBSCR_LIST_INTalready does:before deopting if the index is still negative.
KRRT7 commentedon Jul 10, 2026
yeah, I think i noticed the perf regression in the xml_etree_generate
I'll look into it, thank you.
pythongh-153486: Specialize negative list int subscripts
Revert "pythongh-153486: Specialize negative list int subscripts"
pythongh-153486: Normalize negative tuple indices in JIT optimizer