Created
November 8, 2011 16:54
-
-
Save seantalts/1348350 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
import time | |
input = ['a', 'b', 'c', 'd', 'e', 'f'] | |
iterations = 1000000 | |
start = time.time() | |
for i in xrange(iterations): | |
s = dict([(x.lower(), i) for i, x in enumerate(input)]) | |
end = time.time() | |
print "First thing took %s seconds" % (end - start) | |
start = time.time() | |
for i in xrange(iterations): | |
s = dict((x.lower(), i) for i, x in enumerate(input)) | |
end = time.time() | |
print "second thing took %s seconds" % (end - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment