[Python-3000] Please re-add __cmp__ to python 3000
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Oct 18 01:44:46 CEST 2007
Steven Bethard wrote:
> I'm having troubles coming up with things where the *basic* operator
> is really a cmp-like function.
Think of things like comparing a tuple. You need to work your
way along and recursively compare the elements. The decision
about when to stop always involves ==, whatever comparison
you're trying to do. So if e.g. you're doing <, then you have
to test each element first for <, and if that's false, test
it for ==. If the element is itself a tuple, it's doing this
on its elements too, etc., and things get very inefficient.
If you have a single cmp operation that you can apply to the
elements, you only need to do it once for each element and it
gives you all the information you need.
--
Greg
More information about the Python-3000
mailing list