I wrote an extension for Python 3 in C++
My module is capable of handling arrays like [1.0, 0.0, 0.0].
I want to add support for numpy arrays as well.
I process arrays with the following code:
PyObject * MyFunction(PyObject * self, PyObject * args) {
PyObject * list;
if (!PyArg_ParseTuple(args, "O!:MyFunction", PyList_Type, &list)) {
return 0;
}
int count = (int)PyList_Size(list);
for (int i = 0; i < count; ++i) {
double value = PyFloat_AsDouble(PyList_GET_ITEM(list, i));
// ...
}
}
I want a function that can iterate through this: np.array([2,3,1,0])
TL;DR:
Numpy equivalent for:
PyList_TypePyList_SizePyList_GET_ITEMorPyList_GetItem
cython@sascha