cimport cythonfrom libc.stdlib cimport malloc, free...def process(a, int len): cdef int *my_ints my_ints = <int *>malloc(len(a)*cython.sizeof(int)) if my_ints is NULL: raise MemoryError() for i in xrange(len(a)): my_ints[i] = a[i] with nogil: #once you convert all of your Python types to C types, then you can release the GIL and do the real work ... free(my_ints) #convert back to python return type return value
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)