8000 gh-102598: Remove obsolete optimization from `FORMAT_VALUE` opcode (#… · python/cpython@82eb946 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82eb946

Browse files
authored
gh-102598: Remove obsolete optimization from FORMAT_VALUE opcode (#102599)
1 parent 1a5a141 commit 82eb946

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

Python/bytecodes.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,20 +3026,10 @@ dummy_func(
30263026
value = result;
30273027
}
30283028

3029-
/* If value is a unicode object, and there's no fmt_spec,
3030-
then we know the result of format(value) is value
3031-
itself. In that case, skip calling format(). I plan to
3032-
move this optimization in to PyObject_Format()
3033-
itself. */
3034-
if (PyUnicode_CheckExact(value) && fmt_spec == NULL) {
3035-
/* Do nothing, just transfer ownership to result. */
3036-
result = value;
3037-
} else {
3038-
/* Actually call format(). */
3039-
result = PyObject_Format(value, fmt_spec);
3040-
DECREF_INPUTS();
3041-
ERROR_IF(result == NULL, error);
3042-
}
3029+
result = PyObject_Format(value, fmt_spec);
3030+
Py_DECREF(value);
3031+
Py_XDECREF(fmt_spec);
3032+
ERROR_IF(result == NULL, error);
30433033
}
30443034

30453035
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {

Python/generated_cases.c.h

Lines changed: 17 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0