[Python-Dev] cmp(x,x) (original) (raw)
Raymond Hettinger python at rcn.com
Mon May 24 19:52:29 EDT 2004
- Previous message: [Python-Dev] cmp(x,x)
- Next message: [Python-Dev] cmp(x,x)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Bob Ippolito]
I think the use case mentioned was something like Numeric, where it may be useful for anArray == anotherArray to return an array of bool, not a single True or False
The code in question is in Py_RichCompareBool() which always just returns True or False. That routine is called by list.contains() and many other functions that expect a yes or no answer.
The regular rich comparison function, Py_RichCompare() is the same as it always was and can still return arrays of bools, complex numbers, or anything at all.
IOW, we're still looking for a use case that warrants removing the identity-implies-equality guarantee out of Py_RichCompareBool(). My argument focused on the invariant assumptions that would be broken if this was done. Second, I don't believe that a sane use case will be found for an object x that returns False for "bool(x==x)" and that returns False for "x in [x]". Stretching ones mind to find such an object seems like an exercise in masochism.
Raymond
- Previous message: [Python-Dev] cmp(x,x)
- Next message: [Python-Dev] cmp(x,x)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]