#3571: [with patch, needs review] ivalue field in integer_mod.pyx shouldn't be
public
------------------------------+---------------------------------------------
 Reporter:  craigcitro        |        Owner:  craigcitro
     Type:  defect            |       Status:  assigned  
 Priority:  major             |    Milestone:  sage-3.4.1
Component:  basic arithmetic  |   Resolution:            
 Keywords:                    |  
------------------------------+---------------------------------------------
Changes (by craigcitro):

  * status:  new => assigned
  * summary:  ivalue field in integer_mod.pyx shouldn't be public => [with
              patch, needs review] ivalue field in
              integer_mod.pyx shouldn't be public

Comment:

 The attached patch fixes this issue, and in fact, gives about a 1.5-2X
 speedup on multiplying `IntegerMod_int`s. The interesting part is that
 previous to this patch, the `ivalue` field was occasionally being accessed
 as a Python attribute instead of a Cython attribute! That's why it broke
 if we made the field not `public` in the first place. Oops.

 BEFORE:

 {{{
 sage: R = Integers(100) ; x = R(3) ; y = R(5)
 sage: timeit('x*y')
 625 loops, best of 3: 403 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 370 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 410 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 405 ns per loop
 }}}

 AFTER:

 {{{
 sage: R = Integers(100) ; x = R(3) ; y = R(5)
 sage: timeit('x*y')
 625 loops, best of 3: 190 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 213 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 174 ns per loop
 sage: timeit('x*y')
 625 loops, best of 3: 191 ns per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/3571#comment:1>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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