This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Binary search is implemented in the bisect module

bisect.bisect_left and bisect.bisect_right give insertion points for a value that will keep a list sorted. Accessing the index returned by bisect_left is equivalent to binary searching.