Passing Numpy arrays to C code wrapped with Cython

后端 未结 2 942
心在旅途
心在旅途 2021-02-18 23:16

I have a small bit of existing C code that I want to wrap using Cython. I want to be able to set up a number of numpy arrays, and then pass those arrays as arguments to the C co

2条回答
  •  轮回少年
    2021-02-19 00:10

    The cython interface code should be created according to the tutorial given here.

    To get a C pointer to the data in a numpy array, you should use the ctypes attribute of the numpy array, which is described here.

提交回复
热议问题