On 24/12/14 13:07, Sturla Molden wrote:

> v
>
> cdef intp_t checksize(intp_t n):
>       while not (n % 5): n /= 5
>       while not (n % 3): n /= 3
>       while not (n % 2): n /= 2
>       return (1 if n == 1 else 0)
>
> def _next_regular(target):
>       cdef intp_t n = target
>       while not checksize(n):
>           n += 1
>       return n


Blah, old code, with current Cython this should be:


from numpy cimport intp_t
cimport cython

@cython.cdivision(True)
cdef intp_t checksize(intp_t n):
      while not (n % 5): n //= 5
      while not (n % 3): n //= 3
      while not (n % 2): n //= 2
      return (1 if n == 1 else 0)

def _next_regular(target):
      cdef intp_t n = target
      while not checksize(n):
          n += 1
      return n



Sturla





_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to