#14054: Cythoned UniqueRepresentation
-----------------------------------------------+----------------------------
Reporter: SimonKing | Owner: tbd
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.8
Component: performance | Resolution:
Keywords: cython UniqueRepresentation | Work issues:
Report Upstream: N/A | Reviewers: Travis
Scrimshaw
Authors: Simon King | Merged in:
Dependencies: #14017, #6495 | Stopgaps:
-----------------------------------------------+----------------------------
Changes (by SimonKing):
* dependencies: #14017 => #14017, #6495
Old description:
> `UniqueRepresentation` provides a comfortable way to create unique parent
> structures, and automatically provides a hash and certain comparison
> methods.
>
> Problems:
>
> - It relies on a metaclass, namely `ClasscallMetaclass` and thus has to
> be a Python class. That's bad for speed.
> - It combines two features, namely a cache and unique instance behaviour.
> But in many some cases we want a cache so that two distinct instances can
> still be equal.
>
> Here, I suggest to
>
> 1. separate the two features, by creating a new class
> `sage.unique_representation.CachedRepresentation` as one base of
> `UniqueRepresentation`.
> 2. create a new cdef class `sage.misc.fast_methods.WithRichCmpById`, that
> provides hash and rich comparison, as expected for unique instance
> behaviour.
>
> __Apply__
>
> - [attachment:trac14054_fast_methods.patch]
New description:
`UniqueRepresentation` provides a comfortable way to create unique parent
structures, and automatically provides a hash and certain comparison
methods.
Problems:
- It relies on a metaclass, namely `ClasscallMetaclass` and thus has to be
a Python class. That's bad for speed.
- It combines two features, namely a cache and unique instance behaviour.
But in many some cases we want a cache so that two distinct instances can
still be equal.
Here, I suggest to
1. separate the two features, by creating a new class
`sage.unique_representation.CachedRepresentation` as one base of
`UniqueRepresentation`.
2. create a new cdef class `sage.misc.fast_methods.WithRichCmpById`, that
provides hash and rich comparison, as expected for unique instance
behaviour.
__Apply__
- [attachment:trac14054_fast_methods-5.8.patch]
--
Comment:
This will not go into 5.7 anyway. Hence, I was rebasing against #6495
(which is a minor change anyway). In addition, I took into account your
comments:
- I rename the new class into `WithEqualityById`.
- I move `FastHashable_class` back into category_singleton (wrong as this
may be...)
I hope this addresses all complaints.
Apply trac14054_fast_methods-5.8.patch
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14054#comment:22>
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.