#18361: CategoryObject: never cache gens_dict
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.7
      Component:  categories         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:  Vincent Delecroix
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/categoryobject__always_cache_gens_dict|  
1c26046a6ae31a03ea375b9afa1e7f7ab444ecba
   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. There is a `cdef
> public` attribute `_gens_dict` in the subclass `ParentWithGens`. This
> attribute should be moved to `CategoryObject`.

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. It turns out that
 caching this doesn't really matter since `gens_dict()` is not used in
 critical code, so we can just remove the funny "caching".

--

--
Ticket URL: <http://trac.sagemath.org/ticket/18361#comment:20>
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.

Reply via email to