bpo-38626: Add comment explaining why __lt__ is used. (GH-16978)
https://bugs.python.org/issue38626
This commit is contained in:
parent
457306bddb
commit
3c88199e0b
|
@ -29,6 +29,7 @@ def bisect_right(a, x, lo=0, hi=None):
|
||||||
hi = len(a)
|
hi = len(a)
|
||||||
while lo < hi:
|
while lo < hi:
|
||||||
mid = (lo+hi)//2
|
mid = (lo+hi)//2
|
||||||
|
# Use __lt__ to match the logic in list.sort() and in heapq
|
||||||
if x < a[mid]: hi = mid
|
if x < a[mid]: hi = mid
|
||||||
else: lo = mid+1
|
else: lo = mid+1
|
||||||
return lo
|
return lo
|
||||||
|
@ -63,6 +64,7 @@ def bisect_left(a, x, lo=0, hi=None):
|
||||||
hi = len(a)
|
hi = len(a)
|
||||||
while lo < hi:
|
while lo < hi:
|
||||||
mid = (lo+hi)//2
|
mid = (lo+hi)//2
|
||||||
|
# Use __lt__ to match the logic in list.sort() and in heapq
|
||||||
if a[mid] < x: lo = mid+1
|
if a[mid] < x: lo = mid+1
|
||||||
else: hi = mid
|
else: hi = mid
|
||||||
return lo
|
return lo
|
||||||
|
|
Loading…
Reference in New Issue