[Python-Dev] Subtle difference between f-strings and str.format()

Serhiy Storchaka storchaka at gmail.com
Fri Mar 30 06:05:59 EDT 2018


30.03.18 02:16, Steven D'Aprano пише:
> Is there a down-side to 2b? It sounds like something you might end up
> doing at a later date regardless of what you do now.

This complicate the compiler and the eval loop, especially in the case 
of nested substitutions in formats, like

     f'{value:+{width:d}.{prec:d}f}'

The speed gain can be too small. The complex implementation of the 
opcode should be tightly integrated with the ceval loop, otherwise we 
can get a slow down, as in one of my experimental implementation of 
BUILD_STRING (https://bugs.python.org/issue27078#msg270505).

The exact benefit is unknown until this feature be implemented.



More information about the Python-Dev mailing list