Created
May 9, 2012 17:19
-
-
Save lsbardel/2646882 to your computer and use it in GitHub Desktop.
str number benchmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import timeit | |
>>> timeit.Timer('str(n)','n=100000').timeit() | |
0.31551924882785443 | |
>>> timeit.Timer('"%s"%n','n=100000').timeit() | |
0.27519383648404983 | |
>>> timeit.Timer('"{0}".format(n)','n=100000').timeit() | |
0.5812355446599895 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The previous benchmark was wrong.
Check stackoverflow thread http://stackoverflow.com/questions/10530315/str-performance-in-python