【发布时间】:2016-04-10 05:43:31
【问题描述】:
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
上面的代码给我一个错误(类型不是专门的),任何人都知道如何解决这个问题,谢谢。
【问题讨论】:
-
它会给你什么样的错误?此外,您设置
idx值的那一行也很疯狂。你想做什么?我们很有可能可以简化它。 -
抱歉代码不清楚,我想返回数组中的目标位置,谢谢。