From ddf20a845f0614c13f3a4419541883717c574c11 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 28 Oct 2019 21:18:06 -0700 Subject: [PATCH] bpo-38626: Add comment explaining why __lt__ is used. --- Lib/bisect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/bisect.py b/Lib/bisect.py index 9786fc9d87c5ef5..8f3f6a3fe35ffea 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