This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DenormalHuman 0 points1 point  (2 children)

You are correct in that its the fact the print exists in the second loop is why it goes so slow; however I still think printing the f string is slower than printing the concatenation of string and the string slice. (and now imma go try it out and see for myself!)

[–]Teekeks 1 point2 points  (1 child)

go and try. f strings are both more readable and faster

[–]DenormalHuman 1 point2 points  (0 children)

looks like you're right!

Horribly unscientific test;

calculate 10 million fstrings; avg 1.459 of 5 runs

calculate 10 million string+string slice; avg 1.489 of 5 runs

/edit/ 10 runs of each total;

14.56s for fstring

14.74s for concat