Guido rethinking removal of cmp from sort method

Ian Kelly ian.g.kelly at gmail.com
Tue Mar 15 13:00:56 EDT 2011


On Tue, Mar 15, 2011 at 2:00 AM, Paul Rubin <no.email at nospam.invalid> wrote:
> Ian Kelly <ian.g.kelly at gmail.com> writes:
>> I would think that you can sort them with key as long as none of the
>> sequences are equal (which would result in an infinite loop using
>> either method).  Why not this?
>
> Yes you can do something like that, but look how ugly it is compared
> with using cmp.

Actually, how would you do it with cmp?  You would need to tee off the
iterators in some way so that each comparison gets the same data as
the last one, which sounds like a major hassle.

Or were you talking about passing in generator functions rather than
generator objects and reinitializing them for each comparison?  If
that's the case then the key version can be a fair amount simpler
since you wouldn't need to bother with caching.



More information about the Python-list mailing list