Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Reduce misses in BINARY_SUBSCR_LIST_INT
  • Loading branch information
sweeneyde committed Dec 12, 2022
commit ced2545ed998af4a125140f2d5bfd1897859e3ef
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