On 10/17/07, Steven Bethard <[EMAIL PROTECTED]> wrote:
> I'm having troubles coming up with things where the *basic* operator
> is really a cmp-like function.

Here's one. When implementing the '<' operator on lists or tuples, you
really want to call the 'cmp' operator on the individual items,
because otherwise (if all you have is == and <) the algorithm becomes
something like "compare for equality until you've found the first pair
of items that are unequal; then compare those items again using < to
decide the final outcome". If you don't believe this, try to implement
this operation using only == or < without comparing any two items more
than once.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to