8000 bpo-38626: Add comment explaining why __lt__ is used. (GH-16978) · shihai1991/cpython@efb07e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit efb07e7

Browse files
rhettingershihai1991
authored andcommitted
bpo-38626: Add comment explaining why __lt__ is used. (pythonGH-16978)
https://bugs.python.org/issue38626
1 parent 9fce7c1 commit efb07e7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/bisect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def bisect_right(a, x, lo=0, hi=None):
2929
hi = len(a)
3030
while lo < hi:
3131
mid = (lo+hi)//2
32+
# Use __lt__ to match the logic in list.sort() and in heapq
3233
if x < a[mid]: hi = mid
3334
else: lo = mid+1
3435
return lo
@@ -63,6 +64,7 @@ def bisect_left(a, x, lo=0, hi=None):
6364
hi = len(a)
6465
while lo < hi:
6566
mid = (lo+hi)//2
67+
# Use __lt__ to match the logic in list.sort() and in heapq
6668
if a[mid] < x: lo = mid+1
6769
else: hi = mid
6870
return lo

0 commit comments

Comments
 (0)
0