Using Numpy C API with boost python numeric
Is it safe to use direct Numpy C API in Boost Python module together with Boost Python numeric::array (also using numpy)? The function "import_array" must be called before using PyArray_SimpeNew. Will it cause problems if the function "import_array" will be called twice in one module?
I'm pretty sure the numeric::array stuff doesn't actually use the NumPy C API, and hence it doesn't call import_array. It just relies on the Python interface to NumPy objects, which is why it doesn't support things like accessing the raw data pointers. So there shouldn't be any problem with using the NumPy C API with it. That said, I think it's always good practice to follow the NumPy C API docs for multiple source files and define a unique preprocessor symbol to import the NumPy API with, i.e.: http://docs.scipy.org/doc/numpy/reference/c-api.array.html#miscellaneous You may also be interested in this project: https://github.com/ndarray/Boost.NumPy Jim
participants (2)
-
Jim Bosch -
Александров Петр