[Python-checkins] bpo-38626: Add comment explaining why __lt__ is used. (GH-16978)

Miss Skeleton (bot) webhook-mailer at python.org
Tue Oct 29 00:38:57 EDT 2019


https://github.com/python/cpython/commit/3c88199e0be352c0813f145d7c4c83af044268aa
commit: 3c88199e0be352c0813f145d7c4c83af044268aa
branch: master
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: Miss Skeleton (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-10-28T21:38:50-07:00
summary:

bpo-38626:  Add comment explaining why __lt__ is used. (GH-16978)



https://bugs.python.org/issue38626

files:
M Lib/bisect.py

diff --git a/Lib/bisect.py b/Lib/bisect.py
index 9786fc9d87c5e..8f3f6a3fe35ff 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



More information about the Python-checkins mailing list