我似乎无法在 Cython 文档中找到有关此符号实际含义的任何信息。
cdef FLOAT_t[:] numbers
cdef unsigned int i
cdef INDEX_t n_workers
cdef PyObject **workers
cdef list ref_workers #Here to maintain references on Python side
def __init__(Parent self, INDEX_t n_workers, list numbers):
cdef INDEX_t i
self.n_workers = n_workers
self.numbers = np.array(numbers,dtype=float)
self.workers = <PyObject **>malloc(self.n_workers*cython.sizeof(cython.pointer(PyObject)))
#Populate worker pool
self.ref_workers = []
for i in range(self.n_workers):
self.ref_workers.append(Worker())
self.workers[i] = <PyObject*>self.ref_workers[i]
def __dealloc__(Parent self):
free(self.workers)
这个**符号是否意味着它是一个指向 PyObject 的指针?我知道该<>符号是为了取消引用指针,这一行也是如此:
self.workers = <PyObject **>malloc(self.n_workers*cython.sizeof(cython.pointer(PyObject)))
分配未知量的内存,因为 PyObject 的大小在self.workers充满取消引用的 PyObject 之前是未知的?
撒科打诨
相关分类