小编use*_*195的帖子

Cython 迭代 numpy 数组列表而不使用 gil

我想迭代具有不同维度的 numpy 数组列表,并将它们传递给不需要 GIL 的 cython 函数:

# a has T1 rows and M columns
a = np.array([[0.0, 0.1, 0.3, 0.7],
              [0.1, 0.2, 0.1, 0.6],
              [0.1, 0.2, 0.1, 0.6]])

# b has T2 rows and M columns
b = np.array([[1.0, 0.0, 0.0, 0.0],
              [0.1, 0.2, 0.1, 0.6]])

# c has T3 rows and M columns
c = np.array([[0.1, 0.0, 0.3, 0.6],
              [0.5, 0.2, 0.3, 0.0],
              [0.0, 1.0, 0.0, 0.0],
              [0.0, 0.0, 0.1, 0.0]])

array_list = [a, b, c]
N = …
Run Code Online (Sandbox Code Playgroud)

c python numpy cython

5
推荐指数
1
解决办法
2203
查看次数

标签 统计

c ×1

cython ×1

numpy ×1

python ×1