Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``BINARY_SUBSCR_LIST_INT`` instruction is no longer used for negative ``int``s, since that instruction always misses when encountering negative integers.
8 changes: 6 additions & 2 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,12 @@ _Py_Specialize_BinarySubscr(
PyTypeObject *container_type = Py_TYPE(container);
if (container_type == &PyList_Type) {
if (PyLong_CheckExact(sub)) {
_Py_SET_OPCODE(*instr, BINARY_SUBSCR_LIST_INT);
goto success;
if (Py_SIZE(sub) == 0 || Py_SIZE(sub) == 1) {
_Py_SET_OPCODE(*instr, BINARY_SUBSCR_LIST_INT);
goto success;
}
SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
SPECIALIZATION_FAIL(BINARY_SUBSCR,
PySlice_Check(sub) ? SPEC_FAIL_SUBSCR_LIST_SLICE : SPEC_FAIL_OTHER);
Expand Down