The bisect Module
The bisect module uses a bisection algorithm to keep a list in sorted order as items are inserted. bisect’s operation is faster than calling a list’s sort method after each insertion. This section documents the main functions supplied by bisect.
bisect |
Returns the index |
insort |
Like |
Module bisect also supplies functions bisect_left, bisect_right, insort_left, and insort_right for explicit control of search and insertion strategies into sequences that contain duplicates. bisect is a synonym for bisect_right, and insort is a synonym for insort_right.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access