0
私はCythonコード内のすべてのPython呼び出しを純粋なCに変換して、GILを解放して並列化を行えるようにしようとしています。私はので、ループ内でGILを解放する必要がCython:GILを使わずにnumpyのメモリビューからベクトル[pair [double、double]]に移動するにはどうすればいいですか?
cdef double[:,:,:] init=np.random.uniform((10,4,2),dtype=np.float32)
cdef int i
cdef int N=init.shape[0]
for i in range(N):
a=init[i].tolist()
#I then get this list of list
#a=[[1.,1.],[1.,1.],[1.,1.]]
#f acting on list of list
f(a)
:
は、私はそのような何かをしたように、2D numpyの配列から初期化リスト-のサイズ-2のリストと連携するために使用しましたPythonへのすべての呼び出しを削除する必要があります。ベクターを用いて、[ペア[二重、二重]の代わりにリストとFを変更に応じて、私は今持っている:cdef vector[pair[double,double]] a
cdef double[:,:,:] init=np.ones((10,4,2),dtype=np.float32_t)
cdef int i
cdef int N=init.shape[0]
for i in prange(N):
#I need to get a vector[pair[double,double]] from the numpy init[i]
#with f now cdef acting on vector[pair[double,double]]
a=np.asarray(init[i]) #actually works but it goes through Python !
f(a)
INIT [i]を変換する方法ベクトルに(従ってダブルタイプ[::])を[pair [double、double]] pythonを使わずに?