Skip to content

Instantly share code, notes, and snippets.

@cldotdev
Created June 12, 2013 01:27
Show Gist options
  • Select an option

  • Save cldotdev/5762266 to your computer and use it in GitHub Desktop.

Select an option

Save cldotdev/5762266 to your computer and use it in GitHub Desktop.
Performance of Sets and Lists
# http://stackoverflow.com/questions/2831212/python-sets-vs-lists
>>> import timeit
>>> a = set(range(1000000))
>>> b = range(1000000)
>>> def test_a():
... '9999' in a
...
>>> def test_b():
... '9999' in b
...
>>> timeit.timeit(test_a, number=1000000)
0.1480870246887207
>>> timeit.timeit(test_b, number=1000000)
# very long...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment