1

I have an object in Python. This object contains fields of data, that I want to pass to a c++ executable.

I have the source code of this executable.

When I run the executable I want the executable to get the data from my python object, and do calculations with it.

Is this possible using python and C++? If yes what is a good way to do it.

Lukas Mosser
  • 71
  • 1
  • 8
  • 1
    You could use the [Python API](http://docs.python.org/2/extending/) directly, or a 3rd party wrapper like [Boost.Python](http://www.boost.org/doc/libs/1_55_0/libs/python/doc/index.html), or look at any of the other results for searching "Python C++". – Useless Jan 09 '14 at 16:52

1 Answers1

1

You could use something like Protocol Buffers as a data interchange format. Protocol Buffers has built-in support for C++ and Python as standard and a few other languages have been supported by others if you required them.

Using Protocol Buffers you can define your object as a .proto message. You will want this object to contain all the data you require to be passed to your C++ code. You can sendthis data using any kind of stream (network/file) and can be read in by your C++ program (also using Procotol Buffers). Accessing the data is as easy as deserializing the stream.

EDIT You may be interested in Thrift and CapnProto which you could use to achieve similar results.

Hope this helps some.

Crumbs
  • 81
  • 4