我想宣布类似的东西:
cdef vector[Node*] list2node(list my_list):
但是Cython给了我这个错误:
cdef vector[Node*] list2node(list my_list):
^
------------------------------------------------------------
mod.pyx:77:20: Expected an identifier or literal
答案 0 :(得分:6)
您不应该需要*
- vector[Node]
应该为Node指针的向量生成代码。使用Cython 0.14.1:
cdef class Node:
pass
cdef vector[Node] list2node():
pass
cdef vector[int] test_int():
pass
cdef vector[int*] test_intp():
pass
生成C ++代码:
static PyTypeObject *__pyx_ptype_3foo_Node = 0;
static std::vector<struct __pyx_obj_3foo_Node *> __pyx_f_3foo_list2node(void);
static std::vector<int> __pyx_f_3foo_test_int(void);
static std::vector<int *> __pyx_f_3foo_test_intp(void);
答案 1 :(得分:2)