[Python-3000] Python, int/long and GMP

Victor Stinner victor.stinner at haypocalc.com
Fri Sep 28 04:29:39 CEST 2007


I read some days ago a discussion about GMP (license). I wanted to know if GMP 
is really better than current Python int/long implementation. So I wrote a 
patch for python 3000 subversion (rev. 58277).

I changed long type structure with:

struct _longobject {
        mpz_t number;

False is the number 0 and True is 1. marshal module is broken, my patch just 
makes gcc happy.

The most important point is the pystone results:
  original python: 32573.3 pystones/second
  python with GMP: 26666.7 pystones/second

So I can now say that GMP is much slower for Python pystone usage of integers. 
I use 32-bit CPU (Celeron M 420 at 1600 MHz on Ubuntu), so most integers are 
just one CPU word (and not a GMP complex structure).

Victor Stinner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: working-gmp.patch
Type: text/x-diff
Size: 103033 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20070928/18a22c4e/attachment-0001.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: longobject.c
Type: text/x-csrc
Size: 28488 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20070928/18a22c4e/attachment-0001.c 

More information about the Python-3000 mailing list