Why gmp is not in the standard library?

Brian Kelley bkelley at wi.mit.edu
Thu Jan 15 10:45:52 EST 2004


Michael Hudson wrote:
> miki.tebeka at zoran.com (Miki Tebeka) writes:
> 
> 
>>Hello All,
>>
>>On a different thread Skip wrote:
>>
>>>Yes, you're right.  Starting at 2**1000 I found three safe primes quite
>>>quickly.  Using my version I gave up waiting after seeing one safe prime
>>>float by.
>>
>>Which made me think why Python don't use gmp as it's primary math
>>package - we'll get fast results, a lot of number types and much more.
>>
>>Can't think of any reason why Python is implementing its own long
>>numbers...

This discussion partly happened a couple of years ago when mxNumber was 
released from egenix.  Here is a google link:

http://mail.python.org/pipermail/python-list/2001-April/040453.html

>>Can you enlighten me?
> 
> 
> Licensing?  IIRC, GMP is GPL.

So is bsddb and that is included with python.  Anyway, gmp is LGPL'd not 
GPL'd.

> Also, possibly, portability.

GMP is incredibly portable, it does have one large flaw for use with python:

  Q:  I get a Segfault/Bus error in a program that uses GMP to calculate 
numbers with several hundred thousand digits. Why?

A: GMP allocates most temporaries on the stack, and some machines give 
user programs very little stack space by default. See setrlimit(2) for 
information on how to increase the stack allocation. You can also change 
it from the shell (using ulimit or limit depending on the shell). You 
can also configure with --disable-alloca to instead allocate temporaries 
using malloc, but that will make the library run somewhat slower.

Brian




More information about the Python-list mailing list