小编use*_*996的帖子

矢量在Cython中分配

这是我的cython程序

cdef struct Node:
    int v
    Node* next
    Node* pre

def f(int N):
    cdef:
        vector[Node*] narray
        int i
    narray.assign(N, 0)
    for i in xrange(N):
        narray[i] = 0
Run Code Online (Sandbox Code Playgroud)

Cython编译结果:

Error compiling Cython file:
------------------------------------------------------------
...
    cdef:
        vector[Node*] narray
        int i
    narray.assign(N, 0)
    for i in xrange(N):
        narray[i] = 0
             ^
------------------------------------------------------------

testLinkList.pyx:107:14: Compiler crash in AnalyseExpressionsTransform
Run Code Online (Sandbox Code Playgroud)

但我可以使用push_back()在向量的末尾追加值或使用int而不是Node*.怎么了?

python pointers vector cython

6
推荐指数
1
解决办法
785
查看次数

标签 统计

cython ×1

pointers ×1

python ×1

vector ×1