Would there be support for a more general cmp/__cmp__

Christopher Subich csubich.spam.block at spam.subich.block.com
Tue Oct 25 15:25:09 CEST 2005

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 

More information about the Python-list mailing list