Last active
December 18, 2015 11:19
-
-
Save MarkRoddy/5774361 to your computer and use it in GitHub Desktop.
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
mroddy@mroddy-local-vm:~$ python somenums.py | |
range+for_loop time: 16.0733070374 | |
xrange+sum time: 6.43176913261 |
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
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