GH-77273: Better bytecodes for f-strings (GH-6132)

This commit is contained in:
Mark Shannon 2023-06-14 16:15:08 +01:00 committed by GitHub
parent 307bceaa65
commit 1d857da7f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 525 additions and 485 deletions

View file

@ -443,18 +443,20 @@ dis_fstring = """\
%3d RESUME 0
%3d LOAD_FAST 0 (a)
FORMAT_VALUE 0
FORMAT_SIMPLE
LOAD_CONST 1 (' ')
LOAD_FAST 1 (b)
LOAD_CONST 2 ('4')
FORMAT_VALUE 4 (with format)
FORMAT_WITH_SPEC
LOAD_CONST 1 (' ')
LOAD_FAST 2 (c)
FORMAT_VALUE 2 (repr)
CONVERT_VALUE 2 (repr)
FORMAT_SIMPLE
LOAD_CONST 1 (' ')
LOAD_FAST 3 (d)
CONVERT_VALUE 2 (repr)
LOAD_CONST 2 ('4')
FORMAT_VALUE 6 (repr, with format)
FORMAT_WITH_SPEC
BUILD_STRING 7
RETURN_VALUE
""" % (_fstring.__code__.co_firstlineno, _fstring.__code__.co_firstlineno + 1)