[issue4356] Add "key" argument to "bisect" module functions

Dmitry Chichkov report at bugs.python.org
Sat Mar 7 01:44:38 CET 2015


Dmitry Chichkov added the comment:

Use case: a custom immutable array with a large number of items and indirect key field access. For example ctypes.array, memoryview or ctypes.pointer or any other custom container.


1. I'm not sure how anyone can consider a precached key array as a right ans scalable answer. It is just a ridiculuos idea. Precashing key array is a O(N) operation.  While bisect is O(log(N)).

2. @Raymond There is a statement that "adding 'key()' would encourage bad design and steer people after from better solutions."  Well, right now, the design that is being encouraged results in O(N) code. Because lazy developers are just 'pre-cacaching' (copying) the keys!

3. There is a statement that key() have to be called multiple times per item. What?  Why?

4. There is a statement that one can always add a _cmp_ function to an object. This is ridiculuous. The object could be immutable. There should be no need to modify the object/array when all that you need to do is to bisect it.

----------
nosy: +dmtr

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4356>
_______________________________________


More information about the Python-bugs-list mailing list