Comment by aunderscored

1 day ago

If you're interested, fstrings are faster because they directly become bytecode at compile time rather than being a function call at runtime

Thanks for the that bit of info! I was surprised by the speed difference. I have always assumed that most variations of basic string formatting would compile to the same bytecode.

I usually prefer classic %-formatting for readability when the arguments are longer and f-strings when the arguments are shorter. Knowing there is a material performance difference at scale, might shift the balance in favour of f-strings for some situations.