You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bytecode for empty f-string != bytecode for empty normal string #99606
Why do you call that a bug? And why would you write f""?
Aren't they the same thing so shouldn't they have the same bytecode? It's pretty inconsistent with f"string contents" without the replacement fields and the other prefix combos with empty strings (they all use LOAD_CONST). Also sometimes I can forget to remove or subconsciously add f.
The intention was that an f-string without any substitutions would be equivalent to a normal string. These examples are 3.12+. It's true for non-empty strings, it should probably be the same for empty strings. Not that I think it's a big deal.
Activity
pochmann commentedon Nov 20, 2022
Why do you call that a bug? And why would you write
f""?thatbirdguythatuknownot commentedon Nov 20, 2022
Aren't they the same thing so shouldn't they have the same bytecode? It's pretty inconsistent with
f"string contents"without the replacement fields and the other prefix combos with empty strings (they all useLOAD_CONST). Also sometimes I can forget to remove or subconsciously addf.ericvsmith commentedon Nov 20, 2022
The intention was that an f-string without any substitutions would be equivalent to a normal string. These examples are 3.12+. It's true for non-empty strings, it should probably be the same for empty strings. Not that I think it's a big deal.
pythongh-99606: Make code generated for an empty f-string identical t…
Merge branch 'main' into pythongh-99606
gh-99606: Make code generated for an empty f-string identical to that…
pythongh-99606: Make code generated for an empty f-string identical t…
pythongh-99606: Make code generated for an empty f-string identical t…