◐ Shell
clean mode source ↗

Message 314000 - Python tracker

f-string expressions can be formatted in four ways:
   with or without a conversion
   and
   with or without a format specifier

Rather than have one bytecode that parses the opcode argument at runtime it would be more efficient and produce a cleaner interpreter for the compiler to produce one or two bytecode as required.
The bytecodes should be:
  CONVERT_VALUE convert_fn
  FORMAT_SIMPLE
  FORMAT_WITH_SPEC

For simple format expressions with no conversion or format specifier,
which make up about 3/4 of all format expressions in the standard library, just the bytecode FORMAT_SIMPLE need be executed.