[Python-Dev] Rich comparison confusion

Michael Hudson mwh21@cam.ac.uk
22 Jan 2001 00:48:16 +0000


Greg Ewing <greg@cosc.canterbury.ac.nz> writes:

> Guido:
> 
> > I don't understand how these can be not commutative unless they have a
> > side effect on the left argument
> 
> I think he meant "not reflective". If a<b == floor(a,b) and a>b ==
> ceil(a,b), then clearly a<b != b>a.

What's floor of two arguments?  In common lisp, (floor a b) is the
largest integer n such that (<= n (/ a b)), in Python it's a type
error...  if you meant min(a,b), then I then think the programmer who
thinks "min(a,b)" is spelt "a<b" has problems we can't be expected to
deal with (if min has a symbol it's /\, but never mind that).

More generally, people who define their comparison operators in
non-intuitive ways shouldn't really expect intuitive behaviour.  I
thought Guido threatened to document this fact in large letters
somewhere...

Cheers,
M.

-- 
  Premature optimization is the root of all evil in programming.  
                                                       -- C.A.R. Hoare