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

Laura Creighton lac at openend.se
Sun Nov 8 11:57:04 EST 2015


In a message of Sat, 07 Nov 2015 21:23:51 +0800, yueyoum writes:
>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? 发自网易邮箱大师
>-- 
>https://mail.python.org/mailman/listinfo/python-list

It is not clear that what you want to do can be done in the general
sense.  See Alex Martelli's explanation here:
tackoverflow.com/questions/1268252/python-possible-to-share-in-memory-data-between-2-separate-processes/1269055#1269055

Any chance that instead of trying to share a PyDict you could share an
array?  If so, multiprocessing will work for you.

Or the last reference there is to some lower level inter process communication
things you can use in Python.  I have never tried them, so have no idea
how well written the code is.

Laura



More information about the Python-list mailing list