This is a very big question, I suggest starting with Extending and Embedding the Python Interpreter in the Python Guide and then Using the NumPy C / API .
Using the Python C / API without crashes or memory requires a good understanding of the Python reference account and C / API.
I prepared a small example that includes Python Interpreter, creates a NumPy array, creates a Python list, and then calls two Python Functions with an array and a list as arguments. This can serve as a starting point that you could expand.
Python functions first:
import numpy def print_matrix(M): print (M) def transform_matrix(M, L): for x in L: M = M*x return M
Then C ++ code:
// Python headers #include <Python.h> #include <abstract.h> // NumPy C/API headers
source share