cdef int bs_contains_nogil(float_or_int[:] l,float_or_int t,int size) nogil:
cdef int low=0
cdef int high=size-1
cdef int mid=0
while(low<=high):
mid=(low+high)//2
if t==l[mid]:
return mid
elif t < l[mid]:
high=mid-1
else:
low=mid+1
return -(low+1)
@boundscheck(False)
@wraparound(False)
def insertplace_nogil(l,t):
idx=(<object (*)(int[:],int,int)>bs_contains_nogil)(l,t,len(l))
return idx //return the target position
上面的代碼給我一個錯誤(類型不專業),任何人都知道如何解決這個問題,謝謝。Cython融合不能鑄造
它給你什麼樣的錯誤?此外,你設置'idx'值的整個行都很瘋狂。你想做什麼?我們可以簡化這一點的可能性非常高。 –
對不起,沒有清除代碼,我想返回數組中的目標位置,謝謝。 – user3035661