#14214: Cythoned homsets
----------------------------------------------+-----------------------------
       Reporter:  SimonKing                   |         Owner:  tbd             
          
           Type:  enhancement                 |        Status:  needs_work      
          
       Priority:  major                       |     Milestone:  sage-5.9        
          
      Component:  performance                 |    Resolution:                  
          
       Keywords:  Hom, cython, cached method  |   Work issues:  Do not change 
cmp too much
Report Upstream:  N/A                         |     Reviewers:                  
          
        Authors:  Simon King                  |     Merged in:                  
          
   Dependencies:  #14159, #12951, #13184      |      Stopgaps:                  
          
----------------------------------------------+-----------------------------

Comment (by nbruin):

 Replying to [comment:27 SimonKing]:
 > I said that a `CachedMethodCallerNoArgs` ''is'' a property, since it has
 a setter and a getter
 It doesn't have a setter as far as I can see, so it's a "nondata
 descriptor". Python treats those differently, e.g., they can be overridden
 by an instance attribute (which is very important for your application!)

 >with the only difference that for accessing it you need to do A.C() and
 not just A.C.

 which means extra overhead: After looking up `A.C`, executing `C.__get__`,
 there is still a call to be processed on the returned object from that! A
 "property" would already be done by then.

 > If you would define it as a property, then you needed to implement
 setter and getter by yourself. A cached method is more comfortable to use.

 but with more overhead.

 I suspect that (an optimized version of) `lazy_attribute` is potentially
 better for argumentless "cached methods". Incidentally, looking at the
 code there, it seems that `lazy_attribute` prefers to store the result in
 `__cached_methods` rather than use `setattr` to override the descriptor.
 Overriding the descriptor (i.e., storing the value in the instance
 attribute dict if available) should be faster and preferable to looking up
 in `__cached_methods`.

 Shouldn't `lazy_attribute` be cythonized too?

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


Reply via email to