#14054: Cythoned UniqueRepresentation
-----------------------------------------------+----------------------------
Reporter: SimonKing | Owner: tbd
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.7
Component: performance | Resolution:
Keywords: cython UniqueRepresentation | Work issues:
Report Upstream: N/A | Reviewers: Travis
Scrimshaw
Authors: Simon King | Merged in:
Dependencies: #14017 | Stopgaps:
-----------------------------------------------+----------------------------
Comment (by SimonKing):
Replying to [comment:14 nbruin]:
> Replying to [comment:12 SimonKing]:
> > 1. I introduce `provide_hash_by_id`, but I don't use it. Shall it be
deleted?
>
> Yes, you should.
OK.
> > Does this violate the contract of hash functions? Or is it enough that
`hash(a)!=hash(b)` implies `a!=b`?
>
> I think Python requires `hash(a)!=hash(b)` implies `not(a==b)`,
Right, that's a difference.
> In any case, I'm pretty sure that "rich comparison" is fully exhausted
before trying to use `__cmp__`, which is only there because of backward
compatibility.
Nope! See my post on [https://groups.google.com/forum/?fromgroups=#!topic
/sage-devel/EOWWTK-bUm8 sage-devel].
If you have a non-cdef class, then it seems `__richcmp__` is simply
ignored (but methods like `__eq__` have precedence over `__cmp__`). In a
cdef class, `__richcmp__` has priority over `__cmp__` when deciding binary
relations such as ==, <, <=, etc. But for cmp(*,*), `__cmp__` will be
used, even if there is `__richcmp__`!
So, the decisive question is: Do dictionaries compare stuff by cmp(a,b)==0
or by a==b?
It is the latter, and thus making `__richcmp__` compatible with `__hash__`
was the right thing to do.
For now, it needs work, because I will delete the C API hack, and
apparently some script of the patchbot has a complaint...
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14054#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.