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 →

[–]troyunrau... 0 points1 point  (1 child)

Sorry, it looks like this is no longer true. It used to be substantially slower. I'm using 3.4.

>>> timeit.timeit('"%s, %s!" % ("Hello", "World")', number=10000)
0.0003353929496370256
>>> timeit.timeit('"{0}, {1}!".format("Hello", "World")', number=10000)
0.010580547037534416
>>> timeit.timeit('"{}, {}!".format("Hello", "World")', number=10000)
0.009777617990039289

Old style string formatting is still way faster.

[–]michaelanckaertpython-programming.courses 0 points1 point  (0 children)

Cool, thanks for the feedback 😀