Skip to content

Instantly share code, notes, and snippets.

@MarkRoddy
Last active December 18, 2015 11:19
Show Gist options
  • Save MarkRoddy/5774361 to your computer and use it in GitHub Desktop.
Save MarkRoddy/5774361 to your computer and use it in GitHub Desktop.
mroddy@mroddy-local-vm:~$ python somenums.py
range+for_loop time: 16.0733070374
xrange+sum time: 6.43176913261
from time import time
b = time()
x = 0
for i in range(100000000):
x = x + 1
e = time()
print "range+for_loop time: " + str(e - b)
b = time()
x = sum(xrange(100000000))
e = time()
print "xrange+sum time: " + str(e - b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment