问题
I have a bunch of functions written in python (for rapid prototyping). My main project is in C++ and I wanna call these functions from my C++ program.
These functions use some specialized python modules like numpy, pyside etc.
I tried using the "--embed" functionality of Cython to convert these functions to a C file and then compile that to an object file. Only problem is, Cython converts these functions into standalone programs, ie. makes a main() function in the .c files it creates. I don't want that, I just wanna be able to call them from my C++ program and use the results I obtain.
Are there any other alternatives, I could use to achieve this (Python/C API, SWIG etc)? Or am I using cython to embed python wrong?
I am using Python3 and Cython 0.22.1.
来源:https://stackoverflow.com/questions/31516235/wrapping-a-python-function-using-numpy-arrays-in-c