Created
December 15, 2010 15:13
-
-
Save smarnach/742056 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 timeit | |
a = range(10000) | |
da = set(a) | |
def list_first(): | |
return 0 in a | |
def set_first(): | |
return 0 in da | |
def list_last(): | |
return 9999 in a | |
def set_last(): | |
return 9999 in da | |
if __name__ == "__main__": | |
for f in [list_first, set_first, list_last, set_last]: | |
t = timeit.Timer(f) | |
print min(t.repeat(number=10000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment