python 3's adoption

Jonathan Gardner jgardner at jonathangardner.net
Thu Jan 28 00:54:23 CET 2010


On Jan 26, 10:12 pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
>
> I did too, when I first heard cmp was to be dumped. But I changed my mind
> and now agree with the decision to drop cmp. Custom sorts are nearly
> always much better written with key rather than cmp: key adds an O(N)
> overheard to the sorting, while cmp makes sorting O(N**2). In other
> words, key is *much* faster, and generally easier to write as well.
>

Imagine what sort() could do if all the keys were platform-native
types. In other words, if you could bypass the Python compare because
all the keys were native int, char, char*, or float. You can't do that
with cmp either.



More information about the Python-list mailing list