Hi Vincent,
I'm the gmpy2 maintainer and I really should be working on getting the release finished....
I don't know if this will help, but I could expose additional gmpy2 functions via the C-API. For example, GMPy_Number_Add() will add any two native Python or gmpy2 types. It also accepts an optional context argument to control rounding, precision, manage exceptions, etc. Your example (ignoring Cython syntax) would translate into `c=GMPy_Number_Add(a,b,NULL)`. As currently written, it will only recognize native Python or gmpy2 types but the logic could be expanded to include checks for __mpz_, __mpq__, __mpfr__, and __mpc__ methods and automatically convert the objects.
`gmpy2` maintains a free list of objects so there is minimal overhead for create the returned object. This approach may not be as fast as directly calling GMP/MPFR/MPC but it might be a simpler translation of Python/Cython code.
If `gmpy2` is statically linked, it will eliminate the need for local copies of GMP/MPFR/MPC. This would be very helpful for Windows users.
Thanks, Vincent, for helping add the C-API!
Regards,
Case