*** NEW GMP MODULE FOR PYTHON ***
This is release 0.95 of the new gmp module. To use it, you
also need the GNU Multiprecision Library, version 2.0 or better.
Changes since 0.94
* texinfo documentation written
* a few bugfixes
Changes since 0.93:
* gmp.digits() no longer dumps core
Changes since 0.92:
* A fatal off-by-one bug in conversion from mpz integers to python
longs is fixed.
* The constructor gmp.mpz can now take a string of digits and a base
as arguments. You no longer need to use longs when constructing mpz
integers from strings.
* A corresponding .digits(base) method is added.
gmp-2.0.2 is available at all GNU mirrors is available at
all gnu mirrors, for example
ftp://lysator.liu.se/pub/gnu/gmp-2.0.2.tar.gz
This gmp module is an almost complete rewrite of the mpz module
distributed with Python. Most important differences:
* The code requires gmp-2.0. Work arounds for bugs in earlier
versions of the gmp library are removed.
* Modular exponentiation is no longer broken.
* Some optimizations for special cases involving the numbers 0 or 1 are
removed, for simplicity. Perhaps this or something better can be
put back later, if it turns out to be important for performance.
* New functions is_square() and is_prime(). (The latter is
probabilistic, but `is_probably_prime' is too awkward a name).
* Several methods of mpz objects are also available as functions.
* The source is adapted to the new python naming conventions.
* The source is cleaner and more straight-forward, in my opinion.
* The size of the source is reduced significantly.
Also, I changed the name, from mpz to gmp. This is because one may
want to add other gmp types; rational numbers and floats.
The gmp module should be compatible with the old mpz module. For 100%
source compatibility, simply do
import gmp
mpz=gmp
Or change all references to mpz to gmp. However, the modules are
incompatible in the sense that they can't be used at the same time. I
think this is beause of global state inside the gmp library, or memory
allocation, but I haven't investigated that thoroughly.
To install, put the file gmpmodule.c into the Python-1.3/Modules
directory, insert the lines
GMP-2.0=/path/to/gmp/installation
gmp gmpmodule.c -I$(GMP-2.0)/include -L$(GMP-2.0)/lib -lgmp
to the Setup file. Commenting out the old mpz module from the Setup
file is recommended. Then type make in the main Python build
directory.
Until the gmp module is incorporated into the official python source,
bugs can be reported to me. Bugs in the gmp-2.0 library should be
reported to
[email protected], see the manual for details.
Of course, I appreciate not only bug report, but also any other
comments or improvements you may have.
Happy hacking,
/Niels M�ller <
[email protected]>