Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is bisect.bisect different from bisect.bisect_right in Python?

Based on everything that I have seen bisect.bisect and bisect.bisect_right in Python seem to do the same thing. Is there any difference that accounts for the difference in name, or do they have identical behavior and merely a different name?

Obviously bisect.bisect_left is different from both of them, but both bisect and bisect_right seem to always return the rightmost position where insertion of the element would maintain a sorted order.

like image 731
JeffBozo Avatar asked Sep 01 '25 04:09

JeffBozo


1 Answers

They are identical:

>>> import bisect
>>> bisect.bisect is bisect.bisect_right
True

In case you were curious, bisect_right is the original function and bisect is the alias:

>>> bisect.bisect.__name__
'bisect_right'
like image 197
wim Avatar answered Sep 02 '25 18:09

wim