Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions Lib/bisect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ def insort_right(a, x, lo=0, hi=None):
slice of a to be searched.
"""

if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
mid = (lo+hi)//2
if x < a[mid]: hi = mid
else: lo = mid+1
lo = bisect_right(a, x, lo, hi)
a.insert(lo, x)

def bisect_right(a, x, lo=0, hi=None):
Expand Down Expand Up @@ -49,14 +42,7 @@ def insort_left(a, x, lo=0, hi=None):
slice of a to be searched.
"""

if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
mid = (lo+hi)//2
if a[mid] < x: lo = mid+1
else: hi = mid
lo = bisect_left(a, x, lo, hi)
a.insert(lo, x)


Expand Down