bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)

This commit is contained in:
Dong-hee Na 2021-11-18 18:19:58 +09:00 committed by GitHub
parent 0920b61a0c
commit 345ba3f080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 50 deletions

View file

@ -1424,6 +1424,19 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
goto success;
}
break;
case NB_SUBTRACT:
case NB_INPLACE_SUBTRACT:
if (PyLong_CheckExact(lhs)) {
*instr = _Py_MAKECODEUNIT(BINARY_OP_SUBTRACT_INT,
_Py_OPARG(*instr));
goto success;
}
if (PyFloat_CheckExact(lhs)) {
*instr = _Py_MAKECODEUNIT(BINARY_OP_SUBTRACT_FLOAT,
_Py_OPARG(*instr));
goto success;
}
break;
default:
// These operators don't have any available specializations. Rather
// than repeatedly attempting to specialize them, just convert them