Hi all --
I seem to have discovered an inconsistency in the semantics of object
comparison between plain old Python instances and ExtensionClass
instances. (I've cc'd python-dev because it looks as though one *could*
blame Python for the inconsistency, but I don't really understand the
guts of either Python or ExtensionClass enough to know.)
Here's a simple script that shows the difference:
class Simple:
def __init__ (self, data):
self.data = data
def __repr__ (self):
return "<%s at %x: %s>" % (self.__class__.__name__,
id(self),
`self.data`)
def __cmp__ (self, other):
print "Simple.__cmp__: self=%s, other=%s" % (`self`, `other`)
return cmp (self.data, other)
if __name__ == "__main__":
v1 = 36
v2 = Simple (36)
print "v1 == v2?", (v1 == v2 and "yes" or "no")
print "v2 == v1?", (v2 == v1 and "yes" or "no")
print "v1 == v2.data?", (v1 == v2.data and "yes" or "no")
print "v2.data == v1?", (v2.data == v1 and "yes" or "no")
If I run this under Python 1.5.2, then all the comparisons come out true
and my '__cmp__()' method is called twice:
v1 == v2? Simple.__cmp__: self=