Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ctypes, pyrex, swig, or cython for this problem?

I have about 20 simple C++ classes that represent various probability distributions. I would like to make these available in Python. What is the easiest way to do this? I don't mind having a program automatically generate wrappers, but I don't want to retype the classes.

Also, some of my classes use Boost uBLAS libraries. Is there a way to automatically pass in numpy arrays from Python?

like image 934
Neil G Avatar asked Nov 06 '22 05:11

Neil G


1 Answers

Actually, none of those.

I use Boost.Python extensively to operate a C++ library from Python.

There are easy converters for uBlas and NumPy, if you don't mind copying values around. If you do, you can try to get PyUblas to work, which enables memory sharing between NumPy and uBlas.

like image 97
ebo Avatar answered Nov 09 '22 07:11

ebo