簡體   English   中英

在沒有 GIL 的情況下不允許來自 Python 的強制,並行使用 arrays(Cython 中的多線程)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM