#18361: CategoryObject: always cache gens_dict
----------------------------------+------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.7
Component: categories | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
----------------------------------+------------------------
Description changed by jdemeyer:
Old description:
> The `cdef class CategoryObject` has this strange method:
> {{{
> def gens_dict(self):
> r"""
> Return a dictionary whose entries are
> ``{var_name:variable,...}``.
> """
> if HAS_DICTIONARY(self):
> try:
> if self._gens_dict is not None:
> return self._gens_dict
> except AttributeError:
> pass
> v = {}
> for x in self.gens():
> v[str(x)] = x
> if HAS_DICTIONARY(self):
> self._gens_dict = v
> return v
> }}}
> which provides caching only for Python subclasses. This should be a
> Cython attribute instead.
New description:
The `cdef class CategoryObject` has this strange method:
{{{
def gens_dict(self):
r"""
Return a dictionary whose entries are
``{var_name:variable,...}``.
"""
if HAS_DICTIONARY(self):
try:
if self._gens_dict is not None:
return self._gens_dict
except AttributeError:
pass
v = {}
for x in self.gens():
v[str(x)] = x
if HAS_DICTIONARY(self):
self._gens_dict = v
return v
}}}
which provides caching only for Python subclasses. There is a `cdef
public` attribute `_gens_dict` in the subclass `ParentWithGens`. This
attribute should be moved to `CategoryObject`.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/18361#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 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.
For more options, visit https://groups.google.com/d/optout.