Miki Tebeka <[EMAIL PROTECTED]> added the comment: I agree you can get around this with defining __cmp__, however same goes to "sort" and it was added anyway.
My take on it is that sometimes I need to find something in a big list of objects, and I don't like to do DSU and not add __cmp__ to the objects (since some of the lists might be sorted by different attributes - say one list for time and one line for price). I'd prefer if we do implement "key" and add a warning in the docs it might slow you down. Which what will happen in the case of __cmp__ anyway. I don't see why the "key" function should be called all the time on inserted item, it's very easy to cache this value def bisect(a, x, lo=0, hi=None, key=lambda x: x): assert low >= 0, "low must be non-negative" hi = hi or len(a) x_key = key(x) while lo < hi: mid = (lo+hi)//2 if x_key < key(a[mid]): hi = mid else: lo = mid+1 return lo (I'd also wish for "identity" built in, however this is another subject :) _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4356> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com