> > > Don't you still need a tie-breaker index to preserve stability? > > > > No, because the sort algorithm is already stable. > > In which case it makes no sense at all for stability > to be an option, since you'd have to go out of your > way to make it *un*stable! > > The only issue then is to avoid comparing the whole > record, and this presumably should be non-optional > as well. Right. I think we've settled on using small wrapper objects instead of tuples, whose comparison *only* compares the key value, and whose other field contains a reference to the full record. When passing both cmp and key, cmp is passed the key field from the wrapper. The wrapper objects don't need to have any general purpose functionality so their implementation should be very simple. (We *could* go further and have a custom allocator for these objects, but I'm not sure that that's necessary -- pymalloc should be fast enough, and the bulk cost is going to be the O(N log N) behavior of the sort anyway.) --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4