Skip to content

Instantly share code, notes, and snippets.

@lsbardel
Created May 9, 2012 17:19
Show Gist options
  • Save lsbardel/2646882 to your computer and use it in GitHub Desktop.
Save lsbardel/2646882 to your computer and use it in GitHub Desktop.
str number benchmarks
>>> 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
@lsbardel
Copy link
Author

The previous benchmark was wrong.
Check stackoverflow thread http://stackoverflow.com/questions/10530315/str-performance-in-python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment