[Numpy-discussion] Embedding Python - data exchange && no Boost

Thomas Hrabe thrabe@burnham....
Wed May 7 17:13:47 CDT 2008


Hi all,

I am writing an embedded python application in C/C++ with the following features:

1. The user is able to execute python commands (works fine with PyRun_SimpleString)
2. I want the user to be able to load C objects from C into the current python interpreter, so that the user is able to manipulate the python copies with python tools -> no go.

I first wrote a function within a module which is loaded after Py_Initialize(), returning an PyObject.
I thought it might be possible to share a static variable between the module and the C application, where the module function could access the static variable, convert it to a PyObject and provide it to the interpreter.

Think of this procedure in terms of python calls:

import PA; //imports the module in the embedded interpreter
a = PA.set() ; //access the static object, create a PyObject, return it as a

The later python calls should be able to manipulate a and then return it back to C by setting the static object again like
PA.get(a) ; //or similar

However, it turned out that the static object in the interpreter differs from the one in the C program -> other adresses in memory, so that I can not share the memory space.
Does anybody know of a solution for such a problem? Any tips?

I do not use Boost because the program is supposed to process numpy's nd-arrays and, furthermore, must remain independent of additional libraries such as Boost. I'd use it otherwise...

Thank you in advance for your help,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080507/32e8ec84/attachment.html 


More information about the Numpy-discussion mailing list