Created
April 16, 2015 10:46
-
-
Save sudorandom/97f25dcaf5e58f949c3c to your computer and use it in GitHub Desktop.
Percent formatting vs format()
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
> python -m timeit '["%s" % n for n in range(10000)]' -n 100 | |
100 loops, best of 3: 1.91 msec per loop | |
> python -m timeit '["{}".format(n) for n in range(10000)]' -n 100 | |
100 loops, best of 3: 3.08 msec per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment