[Python-Dev] PEP 498 (interpolated f-string) tweak (original) (raw)

Chris Angelico rosuav at gmail.com
Sun Sep 20 00:42:15 CEST 2015


On Sun, Sep 20, 2015 at 5:36 AM, Eric V. Smith <eric at trueblade.com> wrote:

As the PEP says, the expression with '+' is illustrative, not how it's actually implemented. The implementation currently uses ''.join, although I reserve the right to change it.

or even to

'abc{:spec1}{!r:spec2}def{!s}ghi'.format(expr1, expr2, expr3) That's surprisingly difficult to get right. I've implemented the code at least 3 different ways, and the current implementation seems the most straightforward. I might add a special opcode to use a PyUncodeWriter, though.

Since this is entirely under the control of the parser, there's no particular reason to promise anything about the implementation or its performance metrics. The semantics won't change if CPython 3.7.4 decides to change to using ''.join() instead of concatenation.

Let's not bikeshed the implementation details. I'm sure Eric knows what he's doing.

ChrisA



More information about the Python-Dev mailing list