This is another Python wrapper for GMP.
This wrapper is powered by cppyy, i.e., it wraps libgmpxx, the C++ interface of GMP.
There might be others out there but we are aware of these Python wrappers for GMP.
This wrapper was born out of the necessity for a wrapper for the C++ interface of GMP for pyexactreal so the semantics are exactly the same as in the C++ interface and the Python code involved is quite minimal. It does not actually aim to compete with any of the existing wrappers, we just needed one that went through cppyy and broke it out of pyexactreal eventually. We have not done much benchmarking yet, however, there is certainly a lot of room for improvement1.
>>> import gmpxxyy, gmpy2
>>> a = gmpxxyy.mpz(1)
>>> %timeit a + a
1.34 µs ± 5.16 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
>>> a = gmpy2.mpz(1)
>>> %timeit a + a
57.3 ns ± 0.28 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
As another downside we have cppyy as a dependency which at the time of this writing is a very heavy one indeed.
You can install this package with conda. Download and install Mambaforge, then run
mamba create -n gmpxxyy gmpxxyy
conda activate gmpxxyy
You recommend to use pixi to work on this project. You can build gmpxxyy and run its test with:
git clone --recurse-submodules https://github.com/flatsurf/gmpxxyy.git
cd gmpxxyy
pixi run -e dev test
1 These benchmarks are not tuned in any way. I just typed them into a Python REPL on my Laptop with conda's IPython. This is not meant to be exact in any way, just to give you a very rough sense of what to expect. If I should really be benchmarking something else instead, please let me know :)