#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 SimonKing):

 Replying to [comment:24 nbruin]:
 > For me, the `self.__cached_method['_domain'] = D` does not work.

 Should be `self.__cached_methods['_domain'] = D` with "s".


 > Furthermore, are you sure property access is not competitive? My tests
 seem to indicate it is:
 > {{{
 > sage: cython("""
 > sage: from sage.misc.cachefunc import cached_method
 > sage: from sage.structure.parent cimport Parent
 > sage: cdef class T(sage.structure.parent.Parent):
 > ...       @cached_method
 > ...       def C(self):
 > ...           return 10
 > ...       property B:
 > ...           def __get__(self):
 > ...               return self.__cached_methods['C'].cache
 > ...           def __set__(self,value):
 > ...               self.__cached_methods['C'].cache=value
 > ...
 > sage: """)
 > sage: A=T()
 > sage: A.C()
 > 10
 > sage: A.B
 > 10
 > sage: timeit('A.C()')
 > 625 loops, best of 3: 389 ns per loop
 > sage: timeit('A.B')
 > 625 loops, best of 3: 229 ns per loop
 > sage: A.C()
 > 20
 > }}}

 I did not say that it is not competitive. I said that a
 `CachedMethodCallerNoArgs` ''is'' a property, since it has a setter and a
 getter, with the only difference that for accessing it you need to do
 A.C() and not just A.C.

 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.

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