Alex Martelli aleax at
Thu Aug 7 20:13:15 CEST 2003

Gary Herron wrote:
> Python has (arbitrarily) long integer support built right in.  For

Oh yes (it's the one bit that initially most attracted me, because
I needed to do some combinatorial-arithmetic computations...), and it's
become even better (faster) in 2.3, with Karatsuba's algorithm for
multiplication.  However...:

> instance:
>>>> ((2**10)**10)**10

[alex at lancelot Lib]$ python '((2**10)**10)**10'
10000 loops, best of 3: 98.5 usec per loop

[alex at lancelot Lib]$ python -s'import gmpy'
100000 loops, best of 3: 6.47 usec per loop

...gmpy's still way faster (at least on my Athlon machine -- I did
originally choose AMD over Intel essentially by benchmarking the
two possibilities on some heavy computations with GMP...), for this
kind of computation.  This kind of speed improvement, one of more
than an order of magnitude, sometimes makes the difference between
a project being feasible or unfeasible, if computations of this kind
are right on a program's bottleneck.  So, gmpy still has a place, IMHO.


More information about the Python-list mailing list