Get rid of sanity check on bsearch; just use __debug__.
authorScott Gasch <[email protected]>
Sun, 5 Jun 2022 05:35:03 +0000 (22:35 -0700)
committerScott Gasch <[email protected]>
Sun, 5 Jun 2022 05:35:03 +0000 (22:35 -0700)
list_utils.py

index 1141af2fe9b6bb8861dfd25c08dab735bfd4ceaf..8f92be30c45fba8531654895f7a03da29b18dae7 100644 (file)
@@ -259,7 +259,7 @@ def scramble(seq: MutableSequence[Any]) -> MutableSequence[Any]:
     return shuffle(seq)
 
 
-def binary_search(lst: Sequence[Any], target: Any, *, sanity_check=False) -> Tuple[bool, int]:
+def binary_search(lst: Sequence[Any], target: Any) -> Tuple[bool, int]:
     """Performs a binary search on lst (which must already be sorted).
     Returns a Tuple composed of a bool which indicates whether the
     target was found and an int which indicates the index closest to
@@ -285,7 +285,7 @@ def binary_search(lst: Sequence[Any], target: Any, *, sanity_check=False) -> Tup
     AssertionError
 
     """
-    if sanity_check:
+    if __debug__:
         last = None
         for x in lst:
             if last is not None: