Skip to content

Commit

Permalink
bpo-38626: Add comment explaining why __lt__ is used. (GH-16978)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger authored and miss-islington committed Oct 29, 2019
1 parent 457306b commit 3c88199
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/bisect.py
Expand Up @@ -29,6 +29,7 @@ def bisect_right(a, x, lo=0, hi=None):
hi = len(a)
while lo < hi:
mid = (lo+hi)//2
# Use __lt__ to match the logic in list.sort() and in heapq
if x < a[mid]: hi = mid
else: lo = mid+1
return lo
Expand Down Expand Up @@ -63,6 +64,7 @@ def bisect_left(a, x, lo=0, hi=None):
hi = len(a)
while lo < hi:
mid = (lo+hi)//2
# Use __lt__ to match the logic in list.sort() and in heapq
if a[mid] < x: lo = mid+1
else: hi = mid
return lo
Expand Down

0 comments on commit 3c88199

Please sign in to comment.