diff options
author | Dong-hee Na <donghee.na@python.org> | 2021-11-18 09:19:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 09:19:58 (GMT) |
commit | 345ba3f080c140dee3102f472bc166c2db191bcc (patch) | |
tree | 302e16c6c660da6dcb5b5400447c24e90e4f4f2b /Python/specialize.c | |
parent | 0920b61a0cb30128287ebafab1df8cad3a3dffdb (diff) | |
download | cpython-345ba3f080c140dee3102f472bc166c2db191bcc.zip cpython-345ba3f080c140dee3102f472bc166c2db191bcc.tar.gz cpython-345ba3f080c140dee3102f472bc166c2db191bcc.tar.bz2 |
bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index cfc21bf..dd15de7 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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 |