#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:
Authors: Simon King | Merged in:
Dependencies: #14017 | Stopgaps:
-----------------------------------------------+----------------------------
Comment (by SimonKing):
FWIW, I finished a more experimental and rather intrusive version of
`UniqueRepresentation`.
Idea:
- Create a cdef function, that results in faster C code than what Cython
makes of
{{{
def __hash__(self):
return id(self)
}}}
- Override tp_hash with this function, for every instance of
`UniqueRepresentation`. Likewise for tp_richcompare.
It remains possible to override those parts of comparison that can't be
decided by looking at identity (such as "a<b" if "a is not b").
It would be great to just define the fast hash and comparison for
`UniqueRepresentation` itself, but alas it seems that subclasses forget
these settings, whether they override `__hash__` or not. See the comments
on sage-devel.
I still think it is a good idea to separate `UniqueRepresentation` from
`CachedRepresentation`, but I am not so sure about ''enforcing'' the
uniqueness behaviour, without the possibility to override it---this
wouldn't be pythonic...
Let the patchbot do some work:
Apply trac14054_fast_methods.patch
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14054#comment:5>
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.