X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=list_utils.py;h=8f92be30c45fba8531654895f7a03da29b18dae7;hb=f6ec577f04044f21076c4c24c6aa2ab784c6cfc9;hp=1141af2fe9b6bb8861dfd25c08dab735bfd4ceaf;hpb=290e40e0bf150ab889ada06e500a5835d3935da6;p=python_utils.git diff --git a/list_utils.py b/list_utils.py index 1141af2..8f92be3 100644 --- a/list_utils.py +++ b/list_utils.py @@ -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: