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

Comment (by nbruin):

 `TripleDict` has `cdef` `get` and `set`, which are directly called in
 coercion. This is faster than relying on the slotted `__getitem__` and
 `__setitem__` calls (which are still a bit better than completely generic
 method lookup). Implementing this for `MonoDict` and ensuring that it's
 used for `_convert_from_hash` and `_coerce_from_hash` speeds things up to
 an extent that we seem to lose any speed regression wrt prior #12313:
 {{{
 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))
 CPU times: user 1.50 s, sys: 0.01 s, total: 1.51 s
 Wall time: 1.51 s
 }}}
 and
 {{{
 sage: x=-20
 sage: def test():
 ....:            for n in xrange(10**7):
 ....:                  _=QQ(x)
 ....:
 sage: %time test()
 CPU times: user 3.70 s, sys: 0.01 s, total: 3.71 s
 Wall time: 3.71 s
 }}}
 I have noticed that these timings can vary quite a bit between compiles
 and branch names. I guess loops this tight get sensitive to cache
 alignment and fortunate code locations.

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

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