Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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,3 @@
The ``BINARY_SUBSCR_LIST_INT`` and ``BINARY_SUBSCR_TUPLE_INT``
instruction are no longer used for negative integers because
those instruction always miss when encountering negative integers.
16 changes: 12 additions & 4 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,17 +1262,25 @@ _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);
goto fail;
}
if (container_type == &PyTuple_Type) {
if (PyLong_CheckExact(sub)) {
_Py_SET_OPCODE(*instr, BINARY_SUBSCR_TUPLE_INT);
goto success;
if (Py_SIZE(sub) == 0 || Py_SIZE(sub) == 1) {
_Py_SET_OPCODE(*instr, BINARY_SUBSCR_TUPLE_INT);
goto success;
}
SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
SPECIALIZATION_FAIL(BINARY_SUBSCR,
PySlice_Check(sub) ? SPEC_FAIL_SUBSCR_TUPLE_SLICE : SPEC_FAIL_OTHER);
Expand Down