PS: sage: class MyClass(UniqueRepresentation, CombinatorialClass): ....: def __init__(self, n): ....: self.n = n ....: CombinatorialClass.__init__(self) ....: def __repr__(self): ....: return "Level %s"%self.n ....: sage: A = MyClass(1) sage: B = MyClass(2) sage: A == B False sage: A == MyClass(1) True sage: %timeit A==B 625 loops, best of 3: 2.34 µs per loop sage: %timeit A is B 625 loops, best of 3: 253 ns per loop
Since MyClass inherits from UniqueRepresentation, comparison should be by identity. But I thought that == would rely on __eq__ (which *is* provided by UniqueRepresentation). Are the 2 microseconds really the to-be-expected overhead of calling UniqueRepresentation.__eq__? Or is A==B relying on __cmp__ and not on __eq__? Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To post to this group, send email to sage-devel@googlegroups.com. To unsubscribe from this group, send email to sage-devel+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en.