Skip to content

Instantly share code, notes, and snippets.

@sudorandom
Created April 16, 2015 10:46
Show Gist options
  • Save sudorandom/97f25dcaf5e58f949c3c to your computer and use it in GitHub Desktop.
Save sudorandom/97f25dcaf5e58f949c3c to your computer and use it in GitHub Desktop.
Percent formatting vs format()
> 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