#14159: Don't install callbacks on values of TripleDict, MonoDict
------------------------------+---------------------------------------------
       Reporter:  nbruin      |         Owner:  tbd         
           Type:  defect      |        Status:  needs_review
       Priority:  major       |     Milestone:  sage-5.8    
      Component:  memleak     |    Resolution:              
       Keywords:              |   Work issues:              
Report Upstream:  N/A         |     Reviewers:  Nils Bruin  
        Authors:  Simon King  |     Merged in:              
   Dependencies:  #13387      |      Stopgaps:              
------------------------------+---------------------------------------------

Comment (by nbruin):

 {{{
 %cython
 cdef class dictest(object):
     cpdef get(self,int k1,int k2,int k3):
         if k1==1 and k2==1 and k3==1:
             return True
         else:
             return False
     def __getitem__(self,k):
         cdef int k1,k2,k3
         try:
             k1,k2,k3=k
         except:
             raise KeyError
         return self.get(k1,k2,k3)
 }}}
 regular method call protocol is pretty expensive:
 {{{
 sage: C=dictest()
 sage: timeit("C.get(1,1,1)")
 625 loops, best of 3: 795 ns per loop
 sage: timeit("C[1,1,1]")
 625 loops, best of 3: 717 ns per loop
 }}}
 (but of course, from cython, one should absolutely use the cdef form)

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