Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98464

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

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: how to copy PyObject * memory data to another memory address?
Date 2015-11-09 03:17 +1100
Message-ID <mailman.138.1446999430.16136.python-list@python.org> (permalink)
References <1446902615952.dslp41enande24vd1gfb0x4r@android.mail.163.com>

Show all headers | View raw


On Sun, Nov 8, 2015 at 12:23 AM, yueyoum <yueyoum@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to copy PyObject * memory data to another memory address? Chris Angelico <rosuav@gmail.com> - 2015-11-09 03:17 +1100

csiph-web