[issue1619060] bisect on presorted list

Raymond Hettinger report at bugs.python.org
Wed Mar 12 23:40:56 CET 2008


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

Guido, what do you think about this one?

It is easy to do and has been requested several times in various forums.
The seeming reasonable basis for the request is that sort and bisect
should fit together like a nut and bolt -- it is somewhat odd to be able
to sort a list by a key function but not be able to search or insert
according to the same key.

My main reservation is that the existence of the API would tend to
encourage bad design.  Elsewhere, the intent of the key function is to
be cheaper than a cmp function (such as with sort() which calls the key
function once per element instead of many times for cmp).  But with
successive bisect/insort calls, a key function could be called multiple
times for the same value.  

The same issue also applies to heapq:
http://bugs.python.org/issue1158313 and
http://bugs.python.org/issue1162363 .

----------
assignee: rhettinger -> gvanrossum
nosy: +gvanrossum

_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1619060>
_____________________________________


More information about the Python-bugs-list mailing list