summaryrefslogtreecommitdiffstats
path: root/Lib/bisect.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-10-29 04:38:50 (GMT)
committerMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2019-10-29 04:38:50 (GMT)
commit3c88199e0be352c0813f145d7c4c83af044268aa (patch)
tree74e708c3fdda8da4ded49eb152ef15c6446bf9ac /Lib/bisect.py
parent457306bddbc0021396504b7349fe0c322b65f7a7 (diff)
downloadcpython-3c88199e0be352c0813f145d7c4c83af044268aa.zip
cpython-3c88199e0be352c0813f145d7c4c83af044268aa.tar.gz
cpython-3c88199e0be352c0813f145d7c4c83af044268aa.tar.bz2
bpo-38626: Add comment explaining why __lt__ is used. (GH-16978)
https://bugs.python.org/issue38626
Diffstat (limited to 'Lib/bisect.py')
-rw-r--r--Lib/bisect.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/bisect.py b/Lib/bisect.py
index 9786fc9..8f3f6a3 100644
--- a/Lib/bisect.py
+++ b/Lib/bisect.py
@@ -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
@@ -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