Gmpy

Gary Herron gherron at islandtraining.com
Thu Aug 7 18:20:32 CEST 2003


On Thursday 07 August 2003 07:30 am, Jean-Pierre Andreaux wrote:
> Gmpy module was a wrapper of the GNU MP library. It seems that no
> evolution is done on this module since 2001. Indeed, Gmpy is not
> supported in Python 2.2 nor 2.3.
>
> My question is the following: what is the better replacement solution
> for manipulating long numbers. I want to do long numbers
> exponentiations. Thanks in advance for your answers.
>
> JP

Python has (arbitrarily) long integer support built right in.  For instance:

>>> ((2**10)**10)**10
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376L

Notice the 'L' on the end of the result implies the value is a "long'
integer, not a 32-bit integer.  

In recent versions of Python, arithmetic on normal integers will
convert to long integers when an overflow occurs.

Is this what you wanted?

Gary Herron









More information about the Python-list mailing list