[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Would there be support for a more general cmp/__cmp__
From: Christopher Subich <csubich.spam.block () spam ! subich ! block ! com>
Date: 2005-10-25 13:25:09
Message-ID: djlbnq$6jm$1 () rumours ! uwaterloo ! ca
[Download RAW message or body]
Antoon Pardon wrote:
> It *is* a definition of an ordering.
>
> For something to be an ordering it has to be anti symmetric and transitive.
>
> The subset relationships on sets conform to these conditions so it is a (partial)
> ordering. Check your mathematic books, Why you would think this is abuse is beyond me
Which is exactly why a < b on sets returns True xor False, but cmp(a,b)
throws an exception.
a <COMPARE> b is a local comparison, asking only for the relationship
between two elements. In some bases, like the complex numbers, some
comparisons are ill-defined.; in others, like sets, they're well-defined
but don't give a total ordering.
cmp(a,b) asks for their relative rankings in some total ordering. For a
space that does not have a total ordering, cmp(a,b) is meaningless at
best and dangerous at worst. It /should/ throw an exception when the
results of cmp aren't well-defined, consistent, antisymmetric, and
transitive.
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic