A
alessiogiovanni.baroni
There are reasons why Python not used the GMP library for implementing
its long type?
its long type?
There are reasons why Python not used the GMP library for implementing
its long type?
There are reasons why Python not used the GMP library for implementing
its long type?
<alessiogiovanni.baroni <at> gmail.com> writes:
Basically, GMP only becomes faster when the numbers are huge.
The other major issue is licensing: as far as I recall, the
various discussions never came to a conclusion about the legal
implications of using GMP.
Benjamin Peterson said:Basically, GMP only becomes faster when the numbers are huge.
<alessiogiovanni.baroni <at> gmail.com> writes:
Basically, GMP only becomes faster when the numbers are huge.
casevh said:Python 3.1 is significantly faster than Python 2.x on 64-bit
platforms. The following times are for multiplication with 2, 30 and
300 decimal digits.
Could you test pow(a,b,c) where a,b,c are each 300 decimal digits?
This is an important operation in cryptography, that GMP is carefully
optimized for. Thanks.
Ok, thanks for your answers. I understand the problems of licensing,
but
we could to learn from GMP's source code to improve the Python's int
implementation,
mainly because, GMP is very fast. We could violate the GPL?
Testing 2 digits. This primarily measures the overhead for call GMP
via an extension module.
...
Apart from that, I'm not sure there's much snot left to be optimized out, as they say...<
Using inline ASM in Python sources isn't an option.
Could you test pow(a,b,c) where a,b,c are each 300 decimal digits?
This is an important operation in cryptography, that GMP is carefully
optimized for. Thanks.
Ok, thanks for your answers. I understand the problems of licensing,
but we could to learn from GMP's source code to improve the Python's
int implementation, mainly because, GMP is very fast.
casevh said:$ py25 -m timeit -s "a=long('23'*150);b=long('47'*150);m=long
('79'*150)" "c=pow(a,b,m)"
10 loops, best of 3: 52.7 msec per loop
$ py31 -m timeit -s ....
100 loops, best of 3: 8.85 msec per loop
$ py25 -m timeit -s ..."import gmpy ...
1000 loops, best of 3: 1.26 msec per loop
Wow, thanks. gmpy = 40x faster than py2.5. Ouch.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.