使用IPC/共享内存将Integer数组从C++传递到Python

Pass Integer array from C++ to Python using IPC/Shared memory

本文关键字:C++ Python 数组 Integer IPC 共享 内存 使用      更新时间:2023-10-16

使用共享内存将int C++数组传递给python程序的最佳方法是什么?例如,我有定义的数组:*

int  arr[100];
for(int i =0;i<100;i++) {
arr[i] = i*2;
}

我会上python程序:[0,2,4,6….200]?

感谢

您可以始终使用pybind11创建一个python模块,并创建一个公开数组内容的函数。pybind11教程,了解复杂性:

https://bastian.rieck.me/blog/posts/2018/cmake_cpp_pybind11_hard_mode/