【发布时间】:2020-11-12 19:21:16
【问题描述】:
是否可以编写一个 Cython 函数,其中 numpy 数组 通过引用 传递(也许是内存视图?),我可以在 Python 中使用这样的函数?
我试过了:
cpdef void my_function(bytes line, int& counter, np.ndarray[np.uint32_t, ndim=2]& sums):
...
...
这里counter 和sums 将通过引用传递。我对后者感兴趣(但很乐意接受关于这两者的批评和建议)。
编译器抛出:
Reference base type cannot be a Python object
我也收到了与cdef 相同的信息,但我不了解问题的完整病因。
【问题讨论】:
-
介绍一下阵列?
shape,尤其是dtype。 -
@hpaulj
unsigned integers和shape = (76 x 74)