#11115: Rewrite cached_method in Cython
---------------------------+------------------------------------------------
   Reporter:  SimonKing    |          Owner:  jason                
       Type:  enhancement  |         Status:  needs_review         
   Priority:  major        |      Milestone:  sage-4.7             
  Component:  misc         |       Keywords:  category cython cache
Work_issues:               |       Upstream:  N/A                  
   Reviewer:               |         Author:  Simon King           
     Merged:               |   Dependencies:                       
---------------------------+------------------------------------------------
Changes (by SimonKing):

  * status:  needs_info => needs_review


Comment:

 There was rather little feedback on sage-devel.

 The example above shows that the increase of memory consumption - at least
 directly after starting sage - is certainly tolerable. The performance
 gain is obvious.

 There remains the question what we shall do with elements versus element
 class of a category. Options:

  1) Do what the patch suggest. Then, every instance of Element can inherit
 a cached method from the element class of a category, regardless whether
 it accepts attribute assignment or not. The cached method will be more
 efficient if you can assign attributes, but at least the cache won't
 break.

  2) Do not support the inheritance of cached methods from the category to
 elements that don't support attribute assignment.

  3) A combination of 1) and 2): If the user defines an attribute
 `__cached_methods` for its element, then it could inherit cached methods
 from the element class of a category.

 I already stated what I'd prefer.

 By the way, I just noticed that elements can currently (with or without
 the patch) ''not'' inherit a cached_in_parent_method. Reason:
 {{{
 sage: class MyCategory(Category):
 ....:     def super_categories(self):
 ....:         return [Objects()]
 ....:     class ElementMethods:
 ....:         @cached_in_parent_method
 ....:         def test_cache(self):
 ....:             return -self
 ....:
 sage: C = MyCategory()
 sage: C.element_class.test_cache
 Traceback (most recent call last):
 ...
 AttributeError: 'NoneType' object has no attribute 'parent'
 }}}

 I think I could make it work. Should I do that here, or better on a
 different ticket (which depends on this)?

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

Reply via email to