且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将numpy整数数组传递给C代码

更新时间:2023-01-14 12:02:02

在启动numpy数组以匹配计算机上的C int时,也可​​以使用dtype=np.dtype("i").

You can also use dtype=np.dtype("i") when initiating a numpy array to match the C int on your machine.

cdef int [:] y_c
c_array = np.ascontiguousarray(y, dtype=np.dtype("i"))