diff options
author | Chillar Anand <chillar@avilpage.com> | 2019-04-08 08:01:09 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-04-08 08:01:09 (GMT) |
commit | 96be3400a97946b0b3d032dd8c3c0561786796f1 (patch) | |
tree | eb4d809f45ec92f0fb8ea9b418fa889b087990e1 /Lib/bisect.py | |
parent | b7eec94c0e86f8ac318b135ca9146fff32b7203a (diff) | |
download | cpython-96be3400a97946b0b3d032dd8c3c0561786796f1.zip cpython-96be3400a97946b0b3d032dd8c3c0561786796f1.tar.gz cpython-96be3400a97946b0b3d032dd8c3c0561786796f1.tar.bz2 |
remove duplicate code in biscet (GH-1270)
Diffstat (limited to 'Lib/bisect.py')
-rw-r--r-- | Lib/bisect.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/Lib/bisect.py b/Lib/bisect.py index 7732c63..9786fc9 100644 --- a/Lib/bisect.py +++ b/Lib/bisect.py @@ -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): @@ -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) |