C/C++
void func(float* xyz1, float* xyz2,int n){
//do something
for(int i=0; i<n;i++){
printf("%f %f\n",xyz1[i],xyz2[i]);
}
}
Python
import numpy as np
n = 1000000
xyz1 = np.random.random((n,)).tolist()
xyz2 = np.random.random((n,)).tolist()
#pass above array to the C/C++ code for further processing.
func(xyz1,xyz2,n) # <-- the call to the c/c++ code
我见过使用更高级的数据结构(如 C++ 的array. 但是,我只想使用基本数据类型(如int和)传递它float *
有什么简单的方法可以做到这一点,比如 PyBind11 或 python 的内置 C 类型?
有只小跳蛙
相关分类