A strange statement in the bisect documentation?

Dmitry Chichkov dchichkov at gmail.com
Fri Mar 6 20:08:08 EST 2015


I was looking over documentation of the bisect module and encountered the following very strange statement there:

>From https://docs.python.org/2/library/bisect.html

...it does not make sense for the bisect() functions to have key or reversed arguments because that would lead to an inefficient design (successive calls to bisect functions would not "remember" all of the previous key lookups).

Instead, it is better to search a list of precomputed keys to find the index of the record in question...


Is that right that the documentation encourages to use O(N) algorithm [by making a copy of all keys] instead of using O(log(N)) bisect with kay=attrgetter?  And claims that O(N) is more efficient than O(log(N))?  

Thanks



More information about the Python-list mailing list