gh-102598: Remove obsolete optimization from FORMAT_VALUE opcode (#102599)

This commit is contained in:
Nikita Sobolev 2023-03-21 10:47:15 +03:00 committed by GitHub
parent 1a5a14183e
commit 82eb9469e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 44 deletions

View file

@ -3026,20 +3026,10 @@ dummy_func(
value = result;
}
/* If value is a unicode object, and there's no fmt_spec,
then we know the result of format(value) is value
itself. In that case, skip calling format(). I plan to
move this optimization in to PyObject_Format()
itself. */
if (PyUnicode_CheckExact(value) && fmt_spec == NULL) {
/* Do nothing, just transfer ownership to result. */
result = value;
} else {
/* Actually call format(). */
result = PyObject_Format(value, fmt_spec);
DECREF_INPUTS();
ERROR_IF(result == NULL, error);
}
result = PyObject_Format(value, fmt_spec);
Py_DECREF(value);
Py_XDECREF(fmt_spec);
ERROR_IF(result == NULL, error);
}
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {