[New-bugs-announce] [issue38626] small change at bisect_left function for easy understanding
Windson Yang
report at bugs.python.org
Mon Oct 28 23:03:16 EDT 2019
New submission from Windson Yang <wiwindson at outlook.com>:
bisect_left should be similar to bisect_right. However, the current implement didn't reflect it. A little bit update for the bisect_left function could make the user easy to understand their relation.
def bisect_left(a, x, lo=0, hi=None):
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
mid = (lo+hi)//2
# <= should be the only difference between bisect_left and bisect_right
if x <= a[mid]: hi = mid
else: lo = mid+1
return lo
----------
components: Library (Lib)
messages: 355606
nosy: Windson Yang
priority: normal
severity: normal
status: open
title: small change at bisect_left function for easy understanding
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38626>
_______________________________________
More information about the New-bugs-announce
mailing list