osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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.