[英]Coercion from Python not allowed without the GIL, using arrays in parallel (multithreading in Cython)
void worker(int *P,int l):
cdef i
with nogil, parallel():
for i in prange(l):
P[i]=1
我正在嘗試在具有多線程的 cython 中使用 arrays .. 但我收到此錯誤:
沒有 GIL 就不允許來自 Python 的強制
數組 P 的初始化如下:
cdef int l=500000
cdef int *P=<int *> malloc(l* sizeof(int))
有什么幫助嗎?
如果您不指定類型(例如cdef i
),則i
是 Python object。 因此,您不允許在nogil
塊中使用i
。 您可能希望cdef int i
或類似的指定i
是 C integer。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.