Skip to content

Instantly share code, notes, and snippets.

@smarnach
Created December 15, 2010 15:13
Show Gist options
  • Save smarnach/742056 to your computer and use it in GitHub Desktop.
Save smarnach/742056 to your computer and use it in GitHub Desktop.
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