Python and GMP.

casevh casevh at gmail.com
Tue Apr 21 09:17:08 EDT 2009


On Apr 21, 5:47 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> casevh <cas... at gmail.com> writes:
> > > Could you test pow(a,b,c) where a,b,c are each 300 decimal digits?
>
> > $ py25 -m timeit -s  "a=long('23'*150);b=long('47'*150);m=long
> > ('79'*150)" "c=pow(a,b,m)"
> > 10 loops, best of 3: 52.7 msec per loop
> > $ py31 -m timeit -s ....
> > 100 loops, best of 3: 8.85 msec per loop
> > $ py25 -m timeit -s  ..."import gmpy ...
> > 1000 loops, best of 3: 1.26 msec per loop
>
> Wow, thanks.  gmpy = 40x faster than py2.5.  Ouch.

Remember this is on a 64-bit platform using the latest versions of
MPIR or GMP. The ratio would be less for older versions or 32-bit
versions.

casevh



More information about the Python-list mailing list