[Python-Dev] PEP 498: Literal String Interpolation is ready for pronouncement

Brett Cannon brett at python.org
Tue Sep 8 19:32:20 CEST 2015


On Tue, 8 Sep 2015 at 10:26 Erik <python at lucidity.plus.com> wrote:

> Hi.
>
> I realise I'm coming late to the party on this, but I have a question
> about something I don't think the PEP makes clear.
>
>
>
> When is the bytecode for the embedded expressions created?


>
>
> Is it when the source code is parsed, or at runtime when the f-string is
> evaluated?
>

It's at compile time.


>
> If the latter, then any process that works on bytecode (introspection
> tools, peep-hole optimisers etc) will need work.
>
> I understand that colorising editors and analysis tools which operate at
> the source code level will need work, that's fair enough.
>
>
> The PEP hints at things in this area in the "Specification", "Code
> equivalence" and "Expression evaluation" sections, and my guess is that
> it will (and should) happen during parsing, but I can't see where it
> comes right out and says it.
>

It doesn't explicitly state it because it's inherent in the fact that it is
implemented in bytecode which is created at compile time for Python source
(typically when a module is imported, but can be when you call compile()).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150908/ef796718/attachment-0001.html>


More information about the Python-Dev mailing list