On 6/8/10 1:16 AM, Rolandb wrote:
sage: timeit('for x in sxrange(1,100000): x.is_square()', number=25)
25 loops, best of 3: 46.3 ms per loop
Still 25% gain....
What if your c_is_square code merely does what is_square does:
cdef is_c_square(Integer x):
return mpz_perfect_square_p(x.value)
(after importing the necessary stuff, of course).
The documentation for MPIR (used in the function above) seems to
describe a method that resembles the methods posted above (at least at a
few-second glance, to me).
Jason
--
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-support
URL: http://www.sagemath.org