diff options
author | Brandt Bucher <brandt@python.org> | 2021-11-15 08:58:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 08:58:23 -0800 |
commit | ec382fac0db6d9159c2d3496a70b7a605545957e (patch) | |
tree | 0b66f6d45808700c7597e9db677434091653c70b /Python | |
parent | 822c3dcce3996e411c1ff5c432c6ac7d2845cfd6 (diff) | |
download | cpython3-ec382fac0db6d9159c2d3496a70b7a605545957e.tar.gz |
bpo-45636: Remove the old %-formatting fast-path (GH-29532)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 8 | ||||
-rw-r--r-- | Python/specialize.c | 12 |
2 files changed, 8 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 0b24cbdcc2..e808aeed73 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4711,14 +4711,6 @@ check_eval_breaker: res = PyNumber_Multiply(lhs, rhs); break; case NB_REMAINDER: - if (PyUnicode_CheckExact(lhs) && - (!PyUnicode_Check(rhs) || PyUnicode_CheckExact(rhs))) - { - // bpo-28598: Fast path for string formatting (but not - // if the RHS is a str subclass). - res = PyUnicode_Format(lhs, rhs); - break; - } res = PyNumber_Remainder(lhs, rhs); break; case NB_OR: diff --git a/Python/specialize.c b/Python/specialize.c index 7e72013cd8..cfc21bf70a 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1380,13 +1380,13 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache) { _PyAdaptiveEntry *adaptive = &cache->adaptive; - if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) { - SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES); - goto failure; - } switch (adaptive->original_oparg) { case NB_ADD: case NB_INPLACE_ADD: + if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) { + SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES); + goto failure; + } if (PyUnicode_CheckExact(lhs)) { if (_Py_OPCODE(instr[1]) == STORE_FAST && Py_REFCNT(lhs) == 2) { *instr = _Py_MAKECODEUNIT(BINARY_OP_INPLACE_ADD_UNICODE, @@ -1409,6 +1409,10 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, break; case NB_MULTIPLY: case NB_INPLACE_MULTIPLY: + if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) { + SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES); + goto failure; + } if (PyLong_CheckExact(lhs)) { *instr = _Py_MAKECODEUNIT(BINARY_OP_MULTIPLY_INT, _Py_OPARG(*instr)); |