[issue21922] PyLong: use GMP

STINNER Victor report at bugs.python.org
Sat Jul 5 14:43:01 CEST 2014


STINNER Victor added the comment:

Hi, I worked on a similar patch 6 years ago, while Python 3.0 was developped:
https://mail.python.org/pipermail/python-dev/2008-November/083315.html
http://bugs.python.org/issue1814

The summary is that using GMP makes Python slower because most numbers are small: fit in [-2^31; 2^31-1], and GMP allocation is expensive.

There is also a license issue: GMP license is GPL which is not compatible with the Python license.

If you want to work on large numbers, you can gmpy:
https://code.google.com/p/gmpy/

"""
The following testcases yield 42x performace improvement:
- 16384-bit RSA on 8 threads on quad-core with HT # GIL released
- Multiplying 5600000-bit ints
- Dividing 6000000-bit ints
- Converting 300000-character str to int(base=10)
- Converting 1250000-bit int to str
"""

That's not a common use case. Run the Python benchmark suite with your patch to see if your patch has a similar overhead than my old patch.
http://hg.python.org/benchmarks

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21922>
_______________________________________


More information about the Python-bugs-list mailing list