Not directly, although you can use Python's pickle module to dump and
load mpmath numbers to files losslessly.
Direct binary input/output functions would certainly be possible to
implement. What are your precise requirements? Do you need to read
numbers in some existing format?
Fredrik
It sounds like what you need is a function to convert a byte array
into a Python long?
Fredrik
I think there is very complicated highly optimized code somewhere in Sage
(http://sagemath.org) for conversion between Python longs and GMP
mpz_t's. If this is what you need, it could be dug up.
William
Here is how long conversion from GMP to Python long takes:
sage: n = 2**6400-1 # gmp by default in sage
sage: timeit('long(n)')
625 loops, best of 3: 2.71 µs per loop
sage: m = long(n)
sage: timeit('ZZ(m)')
625 loops, best of 3: 3.46 µs per loop
William
Hi,
Look in the src and include directories here:
http://sage.math.washington.edu/home/wstein/build/sage-4.1.1/devel/sage/c_lib/
> Would there be any licensing issues since gmpy is LGPL2+?
Yes, there is a problem since the code is licensed GPL2+. However,
I've cc'd the author -- Gonzalo Tornaria -- and I bet he would be
willing to contribute a LGPL2+ version of the code to gmpy. I
certainly endorse that!
-- William
Case