Pass data from Python to C++

Christian Heimes lists at cheimes.de
Thu May 15 17:56:23 EDT 2008


brad schrieb:
> However, other components can be written in a more user friendly, more
> easily maintained language. We've chosen Python for this. The main
> question now is how to pass the computationally heavy info to c++ from
> within Pyhton. os.system is not ideal. Just wondering how other folks do
> this? I have source to some of the c++ code, but some of it is in binary
> from only. It can take stdin or arguments.


You can either embed the C++ system as a shared library in Python or you
can embed the Python interpreter in your C++ app. Either way you should
use Python's buffer interface to access the data of your library. The
buffer interfaces allows you to create a read only or read/write view on
your data without copying the data.

Christian




More information about the Python-list mailing list