Use of cmp() (was Re: Limitation of os.walk)

Aahz aahz at pythoncraft.com
Thu May 13 00:35:54 EDT 2010


[nitpicking one specific point]

In article <pan.2010.05.13.03.29.00 at REMOVE.THIS.cybersource.com.au>,
Steven D'Aprano  <steven at REMOVE.THIS.cybersource.com.au> wrote:
>
>On the other hand a cmp function is specific to sorting, and nothing
>but sorting.

Not quite.  cmp() is useful any time you have an expensive comparison
operation and you need to take three different codepaths depending on
the comparison result.  I don't know what the current code does, but I
used it in the first cut Decimal() class.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.



More information about the Python-list mailing list