[Python-ideas] Add the imath module

Steven D'Aprano steve at pearwood.info
Fri Jul 13 08:26:42 EDT 2018


On Fri, Jul 13, 2018 at 10:10:00AM +0200, Jeroen Demeyer wrote:
> On 2018-07-12 20:11, Steven D'Aprano wrote:
> >about 4.7 seconds to test 2**800 + 1;
> 
> In SageMath:
> 
> sage: n = 2**800+1; timeit('is_prime(n)')
> 625 loops, best of 3: 303 µs per loop
> 
> That's 4 orders of magnitude faster...

Go on, rub it in why don't you...

I'm pretty sure that Sage is using numpy, which would almost certainly 
have a C-based implementation, not pure Python like mine. And it's 
probably making far less conservative choices about the rate of false 
positives it is willing to accept.

And your computer is probably newer and faster than mine :-(

My point was that for casual use, even the bad cases are still fast 
enough for interactive use. If you think 5 seconds is ridiculously slow, 
you've never tried a naive trial division algorithm that took literally 
days to crawl through the millions of divisions needed.

*wink*



-- 
Steve


More information about the Python-ideas mailing list