#13387: Improve MonoDict and TripleDict data structures
----------------------------------+-----------------------------------------
       Reporter:  nbruin          |         Owner:  Nils Bruin                  
  
           Type:  enhancement     |        Status:  needs_review                
  
       Priority:  major           |     Milestone:  
sage-duplicate/invalid/wontfix
      Component:  memleak         |    Resolution:                              
  
       Keywords:                  |   Work issues:                              
  
Report Upstream:  N/A             |     Reviewers:                              
  
        Authors:  Nils Bruin      |     Merged in:                              
  
   Dependencies:  #11521, #12313  |      Stopgaps:                              
  
----------------------------------+-----------------------------------------

Comment (by nbruin):

 Yippee!! using `PyWeakref_GetObject` instead of calling weakrefs is indeed
 a little faster:
 {{{
 sage: M=sage.structure.coerce_dict.MonoDict(23)
 sage: M[ZZ]=1
 sage: %timeit _=M[ZZ]
 625 loops, best of 3: 211 ns per loop
 sage: %timeit _=M[ZZ]
 }}}
 {{{
 sage: x=-20
 sage: def test():
 ....:         for n in xrange(10**7):
 ....:             _=QQ(x)
 ....:
 sage: sage: time test()
 Time: CPU 7.76 s, Wall: 7.79 s
 }}}
 {{{
 sage: def test(RR):
 ....:             for d in range(-20,0):
 ....:                 if abs(RR(quadratic_L_function__numerical(1, d,
 10000) - quadratic_L_function__exact(1, d))) > 0.001:
 ....:                     print "Oops!  We have a problem at d = ", d, "
 exact = ", RR(quadratic_L_function__exact(1, d)), "    numerical = ",
 RR(quadratic_L_function__numerical(1, d))
 ....:
 sage: time test(RealField(50))
 Time: CPU 1.76 s, Wall: 1.77 s
 }}}
 So we shave a little more off (something like 30ns, i.e., some 15% on a
 simple MonoDict lookup)

 Apply trac_13387-rebased.patch trac_13387-fast-weakref-calls.patch

 '''TODO:''' Further improvement: in the coercion framework, hardwire the
 use of MonoDict, provide get and set cdef methods and call those to
 eliminate further method lookup overhead.

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