[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?

Serhiy Storchaka report at bugs.python.org
Wed Jul 13 16:11:37 EDT 2016


Serhiy Storchaka added the comment:

Proposed patch adds the BUILD_STRING opcode and speeds up PyObject_Format() in common cases. It makes f-strings the fastest method for simple formatting.

$ ./python -m timeit -s "x = 2" -- 'f"X is {x}"'
1000000 loops, best of 3: 0.347 usec per loop

----------
Added file: http://bugs.python.org/file43708/fstring_build_string.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27078>
_______________________________________


More information about the Python-bugs-list mailing list