我想在 cython 中使用类似 structarray 的东西,并且我希望这个 structarray 在 python 中像在 cython 中一样容易访问。基于一时兴起,我使用了一个 dtype 的 recarray,它看起来像我想使用的结构。奇怪的是,它只是工作,并允许我使用 ac structarray ,在引擎盖上;),是 python 用户的 numpy recarray。
这是我的例子
# This is a "structarray in cython with numpy recarrays" testfile
import numpy as np
cimport numpy as np
# My structarray has nodes with fields x and y
# This also works without packed, but I have seen packed used in other places where people asked similar questions
# I assume that for two doubles that is …Run Code Online (Sandbox Code Playgroud)