gh-100239: specialize BINARY_OP/SUBSCR for list-slice (#132626)

This commit is contained in:
Irit Katriel 2025-05-01 11:28:52 +01:00 committed by GitHub
parent 3831752689
commit 5529213d4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 552 additions and 354 deletions

View file

@ -2657,6 +2657,10 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
specialize(instr, BINARY_OP_SUBSCR_DICT);
return;
}
if (PyList_CheckExact(lhs) && PySlice_Check(rhs)) {
specialize(instr, BINARY_OP_SUBSCR_LIST_SLICE);
return;
}
unsigned int tp_version;
PyTypeObject *container_type = Py_TYPE(lhs);
PyObject *descriptor = _PyType_LookupRefAndVersion(container_type, &_Py_ID(__getitem__), &tp_version);