[issue40832] hi param in bisect module should not accept negative values
Raymond Hettinger
report at bugs.python.org
Sun May 31 05:56:38 EDT 2020
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
I'm -0 on this one.
Originally, there were no range checks at all. This kept the code small and fast which was important because bisect() is a building block sometimes used in tight loops, random.choices() for example.
Later, a test for negative lo values was added when it was shown that that case sometimes arose in practice. At that time, a check for negative hi value was skipped because it either didn't seem to arise in practice or that it would occur in conjunction with a negative lo value.
Another issue is that the C implementation already uses a default of -1 when hi=None. So adding another check, one that we likely don't really need, would be more invasive and complicated than it seems at first.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40832>
_______________________________________
More information about the Python-bugs-list
mailing list