[Boost.Python] exporting GMP numbers to Python
Hello, I have a c++ library I want to use as a python module. This works quite nice now (thanks to Joel's bugfix). However, some functions of the library return arbitrary precision numbers (GMP) and I need to access them in Python. I found a working GMP Python wrapper in the GMPY module, but I have simply no idea how use it for my purpose. Maybe someone has a link or something similar for me. Jan
On Tuesday 29 November 2005 12:20, Jan Langer wrote:
I found a working GMP Python wrapper in the GMPY module, but I have simply no idea how use it for my purpose.
Short answer: You can either export GMP numbers yourself with Boost::Python, or try to find out how to/from-python conversion is done with the wrapper you found. In the latter case, export boost::python wrappers returning/accepting boost::python::object's and do the conversion manually. -- Ciao, / / /--/ / / ANS
Hans Meine <meine@kogs1.informatik.uni-hamburg.de> writes:
On Tuesday 29 November 2005 12:20, Jan Langer wrote:
I found a working GMP Python wrapper in the GMPY module, but I have simply no idea how use it for my purpose.
Short answer: You can either export GMP numbers yourself with Boost::Python, or try to find out how to/from-python conversion is done with the wrapper you found. In the latter case, export boost::python wrappers returning/accepting boost::python::object's and do the conversion manually.
It's also possible to register custom from_/to_python converters that will automatically convert the GMP numbers using the wrapper from the other extension. http://mail.python.org/pipermail/c++-sig/2002-May/001211.html http://www.boost.org/libs/python/doc/v2/to_python_converter.html -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams -
Hans Meine -
Jan Langer