Hi,

I read the PEP but I don't understand how it is implemented. For me, it
should be a simple preprocessor:

- f'x={x}' is replaced with 'x={0}'.format(x) by the compiler
- f'x={1+1}' is replaced with 'x={0}'.format(1+1)
- f'x={foo()!r}' is replaced with 'x={0!r}'.format(foo())
- ...

That's all. No new language, no new function or method.

It's unclear to me if arbitrary expressions should be allowed or not. If
not, we may pass parameters by keywords instead:

f'x={x}' is replaced with 'x={x}'.format(x=x) by the compiler

'...'.format(...) is highly optimized. In the current PEP, I see that each
parameter is rendered in its own independent buffer (.__format__() method
called multiple times) and then concateneted by ''.join(...). It's less
efficient that using a single call to .format().

Victor

PS: it looks like the gmail application changed the font size in the middle
of my email. I don't know how to use plain text, sorry about that.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to