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?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: how to copy PyObject * memory data to another memory address?
Date Mon, 9 Nov 2015 03:17:02 +1100
Lines 16
Message-ID <mailman.138.1446999430.16136.python-list@python.org> (permalink)
References <1446902615952.dslp41enande24vd1gfb0x4r@android.mail.163.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de Pta7QO468wBp8B8MxNVTlQlqipMH56y/eT3OT/63GzpA==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'json': 0.05; 'objects,': 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject: * ': 0.16; 'wrote:': 0.16; 'memory': 0.17; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'otherwise,': 0.20; 'are.': 0.22; 'am,': 0.23; 'fit': 0.23; 'references': 0.23; 'header:In-Reply- To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; '(e.g.,': 0.27; 'host': 0.28; 'pickle': 0.29; 'convert': 0.29; 'objects': 0.29; "i'm": 0.30; 'another': 0.32; 'consist': 0.33; 'received:google.com': 0.35; 'nov': 0.35; 'serve': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'shared': 0.38; 'data': 0.39; 'format': 0.39; 'well.': 0.40; 'some': 0.40; 'your': 0.60; '8bit%:100': 0.70; 'transfer': 0.73; 'chrisa': 0.84; 'subject:address': 0.84; 'to:none': 0.91; 'processes,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=iDJi62xzipWA6bR5pDenhZVEvaIXq81foEvknaVqII0=; b=dUK8VShJyu6SyrGoEXmjMXbzhVVnjZCEkzdpr1NFNAS4vgrGhR234PQhfqcj7aOvoo 93ZtvtC2HpGVATPw9wjFxMIFJTxe0bRFSZB1/NLqLr5aqGHeQRBrSuTNeSQIzF+/pIgv PWsuMJxPMx4Wljlm0Z3aOVDAVOF3hIFitQ+jAflzymAVc83ooJ5checK8gL6HfIS4rA5 5jDTk7BtYMd7jczliaAeRpGboEAPcIZxN2z3Yq67UfTYUXHQ3mQrAh7OGsCCWMl5n+c6 ge12Y3G0PJ3SDyopvFCQlkXgjFFMV0qQ9uUshH+J+9SdzDt+QOUHhgnskkuWvSZHVHKc UsMg==
X-Received by 10.50.83.38 with SMTP id n6mr18171550igy.92.1446999422280; Sun, 08 Nov 2015 08:17:02 -0800 (PST)
In-Reply-To <1446902615952.dslp41enande24vd1gfb0x4r@android.mail.163.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98464

Show key headers only | 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