Last active
February 28, 2018 01:20
-
-
Save JasonTam/ab3d23ed9a0c4bbc4abf504f3ea6c91b to your computer and use it in GitHub Desktop.
Most of the time `in` is good enough (even for lists)
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
from bisect import bisect_left | |
def in_bs(a, x): | |
i = bisect_left(a, x) | |
return (i != len(a)) and (a[i] == x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment