gpt4 book ai didi

python - 让 python 程序和 c 程序共享数据的最佳方法是什么

转载 作者:太空宇宙 更新时间:2023-11-04 05:38:14 28 4
gpt4 key购买 nike

Python 程序做前端工作,C 程序做后端工作。它们中的每一个都是一个单独的过程。

Python 进程充当主进程,向 C 进程发送信号和事件。

C 进程生成统计信息、计数器和信息,这些信息被发送回 python 进程,由 python 进程显示给用户。

它们之间会进行双工通信

在搜索了不同的技术之后,我发现这些是我可以做到的一些方法:

1. Create a UDP/TCP socket between the 2 processes.
2. Use a memory mapped file.

传递的数据应该是什么格式?

1. Should I use variable size structures?
2. Should I use Tag Length Value Format?
3. Should I use XML?

我可以有一个两个进程都能理解的通用文件吗?

例如,具有要传递的数据格式的通用头文件。

不同种类的数据信息是

1. Signal messages from python to c.
2. Signal messages from c to python.
3. Heartbeat messages from python to c.
4. Stats messages from c to python.
5. Log messages from c to python.
6. Progress messages from c to python.
7. Update messages from python to c

对于C而言,每条消息都是C结构。

最佳答案

不允许评论,所以:为什么是简单的管道 |还不够吗?

关于python - 让 python 程序和 c 程序共享数据的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26991418/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com