#11475: improve prime_pi (speedup + small fixes)
--------------------------------------------------+-------------------------
   Reporter:  rohana                              |          Owner:  was        
                     
       Type:  enhancement                         |         Status:  
needs_review                    
   Priority:  major                               |      Milestone:  sage-4.7.1 
                     
  Component:  number theory                       |       Keywords:  primes, 
prime counting, prime_pi
Work_issues:                                      |       Upstream:  N/A        
                     
   Reviewer:  Yann Laigle-Chapuy, Leif Leonhardy  |         Author:  R. Andrew 
Ohana                 
     Merged:                                      |   Dependencies:             
                     
--------------------------------------------------+-------------------------

Comment(by leif):

 I'd also use `int_fast8_t` and `uint_fast8_t` instead of `int8_t` and
 `uint8_t`, since size doesn't really matter there:
 {{{
 #!patch
 diff --git a/sage/functions/prime_pi.pyx b/sage/functions/prime_pi.pyx
 --- a/sage/functions/prime_pi.pyx
 +++ b/sage/functions/prime_pi.pyx
 @@ -32,7 +32,7 @@
  include '../ext/stdsage.pxi'
  include '../ext/interrupt.pxi'

 -from libc.stdint cimport int8_t, uint8_t, uint32_t, uint64_t
 +from libc.stdint cimport int_fast8_t, uint_fast8_t, uint32_t, uint64_t
  from sage.rings.integer cimport Integer
  from sage.rings.real_mpfr import RealLiteral, create_RealNumber, RR
  from sage.rings.arith import nth_prime
 @@ -134,8 +134,8 @@
      cdef uint32_t __numPrimes
      cdef uint32_t __maxSieve
      cdef uint64_t __maxSieve64
 -    cdef int8_t[2310] __tabS
 -    cdef uint8_t[1619] __smallPi
 +    cdef int_fast8_t[2310] __tabS
 +    cdef uint_fast8_t[1619] __smallPi

      def __dealloc__(self):
          if self.__numPrimes:
 }}}

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