]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38626: Add comment explaining why __lt__ is used. (GH-16978)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 29 Oct 2019 04:38:50 +0000 (21:38 -0700)
committerMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 29 Oct 2019 04:38:50 +0000 (21:38 -0700)
https://bugs.python.org/issue38626

Lib/bisect.py

index 9786fc9d87c5ef54d9e516005a82e4da3dca1381..8f3f6a3fe35ffea711796e6f7c2a19f5add1342d 100644 (file)
@@ -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