File tree 2 files changed +15
-4
lines changed
Misc/NEWS.d/next/Core and Builtins
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change
1
+ The ``BINARY_SUBSCR_LIST_INT `` and ``BINARY_SUBSCR_TUPLE_INT ``
2
+ instructions are no longer used for negative integers because
3
+ those instructions always miss when encountering negative integers.
Original file line number Diff line number Diff line change @@ -1302,17 +1302,25 @@ _Py_Specialize_BinarySubscr(
1302
1302
PyTypeObject * container_type = Py_TYPE (container );
1303
1303
if (container_type == & PyList_Type ) {
1304
1304
if (PyLong_CheckExact (sub )) {
1305
- _py_set_opcode (instr , BINARY_SUBSCR_LIST_INT );
1306
- goto success ;
1305
+ if (Py_SIZE (sub ) == 0 || Py_SIZE (sub ) == 1 ) {
1306
+ _py_set_opcode (instr , BINARY_SUBSCR_LIST_INT );
1307
+ goto success ;
1308
+ }
1309
+ SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
1310
+ goto fail ;
1307
1311
}
1308
1312
SPECIALIZATION_FAIL (BINARY_SUBSCR ,
1309
1313
PySlice_Check (sub ) ? SPEC_FAIL_SUBSCR_LIST_SLICE : SPEC_FAIL_OTHER );
1310
1314
goto fail ;
1311
1315
}
1312
1316
if (container_type == & PyTuple_Type ) {
1313
1317
if (PyLong_CheckExact (sub )) {
1314
- _py_set_opcode (instr , BINARY_SUBSCR_TUPLE_INT );
1315
- goto success ;
1318
+ if (Py_SIZE (sub ) == 0 || Py_SIZE (sub ) == 1 ) {
1319
+ _py_set_opcode (instr , BINARY_SUBSCR_TUPLE_INT );
1320
+ goto success ;
1321
+ }
1322
+ SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
1323
+ goto fail ;
1316
1324
}
1317
1325
SPECIALIZATION_FAIL (BINARY_SUBSCR ,
1318
1326
PySlice_Check (sub ) ? SPEC_FAIL_SUBSCR_TUPLE_SLICE : SPEC_FAIL_OTHER );
You can’t perform that action at this time.
0 commit comments