Skip to content

Instantly share code, notes, and snippets.

@tomislater
Last active December 24, 2015 20:19
Show Gist options
  • Select an option

  • Save tomislater/6857001 to your computer and use it in GitHub Desktop.

Select an option

Save tomislater/6857001 to your computer and use it in GitHub Desktop.
>>> import bisect
>>> from timeit import timeit
>>> from random import randint
>>> def bisect_sort():
>>> l = [randint(0, 300000) for x in xrange(1000000)]
>>> bisect.bisect_left(l, 42)
>>> print timeit(bisect_sort, number=100)
117.30470705
>>> def list_sort():
>>> l = [randint(0, 300000) for x in xrange(1000000)]
>>> l.sort()
>>> l[42]
>>> print timeit(list_sort, number=100)
222.244460821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment