On Jan 23, 2:43 pm, Simon King <simon.k...@uni-jena.de> wrote:
> 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__?

I guess so, because all indication is that MyClass does compare by
identity. Note that CombinatorialClass does not have an __eq__ and
that its __cmp__ is by string repr (whatever the wisdom of that is).
However, if we ensure two distinct instances have the same repr, we
still get:

sage: A=MyClass(1)
sage: B=MyClass(2)
sage: A
Level 1
sage: B
Level 2
sage: B.n=1
sage: B
Level 1
sage: repr(A) == repr(B)
True
sage: A is B
False
sage: A == B
False

The fact that UniqueRepresentation does not provide __cmp__ is not
strange. The rich comparison methods are preferred, and
UniqueRepresentation chooses not to implement "__lt__" and "__gt__".
Your cython version will have to return NotImplemented for those.

Great work, by the way! It's interesting to see that parents being
unique is now required for coercion to work efficiently.

-- 
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.


Reply via email to