[New-bugs-announce] [issue33092] The bytecode for f-string formatting is inefficient.

Mark Shannon report at bugs.python.org
Sat Mar 17 08:33:10 EDT 2018


New submission from Mark Shannon <mark at hotpy.org>:

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.

----------
components: Interpreter Core
messages: 314000
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: The bytecode for f-string formatting is inefficient.
type: performance
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33092>
_______________________________________


More information about the New-bugs-announce mailing list