#11115: Rewrite cached_method in Cython
---------------------------+------------------------------------------------
   Reporter:  SimonKing    |       Owner:  jason                
       Type:  enhancement  |      Status:  needs_review         
   Priority:  major        |   Milestone:  sage-4.7             
  Component:  misc         |    Keywords:  category cython cache
     Author:  Simon King   |    Upstream:  N/A                  
   Reviewer:               |      Merged:                       
Work_issues:               |  
---------------------------+------------------------------------------------

Comment(by SimonKing):

 In order to be on the safe side, I made some timings for the patches from
 #9138 (on top of #9944), and I'd like to repeat these timings here, with
 this patch applied additionally.

 {{{
 $ ./sage -startuptime
 ...
 == Slowest (including children) ==
 1.244 sage.all (None)
 0.280 sage.schemes.all (sage.all)
 0.243 sage.misc.all (sage.all)
 0.162 elliptic_curves.all (sage.schemes.all)
 ...
 }}}
 So, there is no slow-down, compared with the timings from an unpatched
 Sage on the same machine, as reported on #9138.


 Here is an arithmetical example:
 {{{
 sage: B.<t> = PolynomialRing(Integers(125))
 sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + B(1/4))
 sage: x, T = R.gens()
 sage: timeit('x*T')
 625 loops, best of 3: 893 µs per loop
 }}}
 That is about the same as with the patches from #9944 and #9138, but
 slower than with an unpatched Sage.

 I found that one can use the improved cached_methods to considerably speed
 up the arithmetics. Namely, in the multiplication, the method `modulus()`
 from sage.rings.polynomial.polynomial_ring is called repeatedly. The
 `modulus()` method returns ´self.basering().characteristic()`. When I put
 that method under a cached_method decorator, the timing looks much better:
 {{{
 sage: B.<t> = PolynomialRing(Integers(125))
 sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + B(1/4))
 sage: x, T = R.gens()
 sage: timeit('x*T')
 625 loops, best of 3: 253 µs per loop
 }}}
 That is much faster than without patches, which is 501 µs!!.

 Currently, I try to find some places where using a cached_method might be
 beneficial. As I have demonstrated in previous posts, there are chances to
 speed methods up that do nothing more but "`return self.__some_argument`".

 But independent of that possible second patch, I think the first patch can
 be reviewed.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11115#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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to