#11115: Allow for extension classes to inherit cached methods from their
category
---------------------------+------------------------------------------------
Reporter: SimonKing | Owner: jason
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.7
Component: misc | Keywords: category cython cache
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
---------------------------+------------------------------------------------
Comment(by SimonKing):
The reason is as follows (compare #8611):
The cached method f has a getter method, that returns a
`CachedMethodCaller` and tries to assign it to O as an attribute. That
assignment fails. Hence, whenever f is called again, a new instance of the
`CachedMethodCaller` is created. Note that before #8611, that was always
the case (not very efficient).
Moreover, the cached method would try to cache its return values in a
dictionary assigned to O - again, it fails. So, caching can not work.
My suggestion is as follows.
We want, in particular, that caching works for the base classes Element
and Parent. I propose to provide them with a public cdef method
`__cached_methods` (a dictionary), that is used by the getter method of
the cached method to store the resulting `CachedMethodCaller`, if storing
it as an attribute fails.
Concerning the cache for storing the return values of f: It can not be
stored in a dict as an attribute of O. But by #8611, there is a dict
O.f.cache that is used for storing anyway.
So, in a nutshell, it simply works (and I already have a patch that only
remains to be documented).
I tried to extend that approach to `SageObject` (from which both Parent
and Element inherit), but providing `SageObject` with cdef attributes will
not work, since in some places there is a double inheritance, e.g., from
`SageObject` and `list`.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11115#comment:1>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.