how to copy PyObject * memory data to another memory address?

Chris Angelico rosuav at gmail.com
Sun Nov 8 11:17:02 EST 2015


On Sun, Nov 8, 2015 at 12:23 AM, yueyoum <yueyoum at gmail.com> wrote:
> I'm working on a C program that has Python embedded. The host program is multi processes, which communicate via shared memory (mmap). I create a Python object (e.g., PyDict_New) in one process. How can I copy this data to shared memory so that the other process can obtain this data and convert to Python Object? 发自网易邮箱大师
>

The best way to do this would be to serialize it in some format - JSON
is a good choice, if all your data can fit into that format;
otherwise, consider the Pickle format. Python objects consist of lots
of references to other objects, so it's difficult to transfer them
from one to another as they are. JSON will serve you well.

ChrisA



More information about the Python-list mailing list