mirror of https://github.com/python/cpython
bpo-45636: Remove the old %-formatting fast-path (GH-29532)
This commit is contained in:
parent
822c3dcce3
commit
ec382fac0d
|
@ -0,0 +1,2 @@
|
||||||
|
Remove an existing "fast path" for old-style string formatting, since
|
||||||
|
it no longer appears to have any measurable impact.
|
|
@ -4711,14 +4711,6 @@ check_eval_breaker:
|
||||||
res = PyNumber_Multiply(lhs, rhs);
|
res = PyNumber_Multiply(lhs, rhs);
|
||||||
break;
|
break;
|
||||||
case NB_REMAINDER:
|
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);
|
res = PyNumber_Remainder(lhs, rhs);
|
||||||
break;
|
break;
|
||||||
case NB_OR:
|
case NB_OR:
|
||||||
|
|
|
@ -1380,13 +1380,13 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
|
||||||
SpecializedCacheEntry *cache)
|
SpecializedCacheEntry *cache)
|
||||||
{
|
{
|
||||||
_PyAdaptiveEntry *adaptive = &cache->adaptive;
|
_PyAdaptiveEntry *adaptive = &cache->adaptive;
|
||||||
|
switch (adaptive->original_oparg) {
|
||||||
|
case NB_ADD:
|
||||||
|
case NB_INPLACE_ADD:
|
||||||
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
|
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
|
||||||
SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES);
|
SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
switch (adaptive->original_oparg) {
|
|
||||||
case NB_ADD:
|
|
||||||
case NB_INPLACE_ADD:
|
|
||||||
if (PyUnicode_CheckExact(lhs)) {
|
if (PyUnicode_CheckExact(lhs)) {
|
||||||
if (_Py_OPCODE(instr[1]) == STORE_FAST && Py_REFCNT(lhs) == 2) {
|
if (_Py_OPCODE(instr[1]) == STORE_FAST && Py_REFCNT(lhs) == 2) {
|
||||||
*instr = _Py_MAKECODEUNIT(BINARY_OP_INPLACE_ADD_UNICODE,
|
*instr = _Py_MAKECODEUNIT(BINARY_OP_INPLACE_ADD_UNICODE,
|
||||||
|
@ -1409,6 +1409,10 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
|
||||||
break;
|
break;
|
||||||
case NB_MULTIPLY:
|
case NB_MULTIPLY:
|
||||||
case NB_INPLACE_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)) {
|
if (PyLong_CheckExact(lhs)) {
|
||||||
*instr = _Py_MAKECODEUNIT(BINARY_OP_MULTIPLY_INT,
|
*instr = _Py_MAKECODEUNIT(BINARY_OP_MULTIPLY_INT,
|
||||||
_Py_OPARG(*instr));
|
_Py_OPARG(*instr));
|
||||||
|
|
Loading…
Reference in New Issue