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

Skip to content

Commit af512cc

Browse files
sobolevnFidget-Spinner
authored andcommitted
pythongh-102598: Remove obsolete optimization from FORMAT_VALUE opcode (python#102599)
1 parent f357fc7 commit af512cc

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

Python/bytecodes.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,20 +3254,10 @@ dummy_func(
32543254
value = result;
32553255
}
32563256

3257-
/* If value is a unicode object, and there's no fmt_spec,
3258-
then we know the result of format(value) is value
3259-
itself. In that case, skip calling format(). I plan to
3260-
move this optimization in to PyObject_Format()
3261-
itself. */
3262-
if (PyUnicode_CheckExact(value) && fmt_spec == NULL) {
3263-
/* Do nothing, just transfer ownership to result. */
3264-
result = value;
3265-
} else {
3266-
/* Actually call format(). */
3267-
result = PyObject_Format(value, fmt_spec);
3268-
DECREF_INPUTS();
3269-
ERROR_IF(result == NULL, error);
3270-
}
3257+
result = PyObject_Format(value, fmt_spec);
3258+
Py_DECREF(value);
3259+
Py_XDECREF(fmt_spec);
3260+
ERROR_IF(result == NULL, error);
32713261
}
32723262

32733263
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top: *bottom)) {

Python/generated_cases.c.h

Lines changed: 4 additions & 15 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