I want to integrate a Python application into my C++ application. The communication has to be bidirectional, as shown in the following example:
C++:
void main() {
# call python code
return 0;
}
int computeResult(int value) {
int result;
// do stuff with value
return result;
}
Python:
def run(value):
result = computeResult(value) # call computeResult of C++ code
...
for i in xrange(0, 10):
run(i)
I thought about calling the Python code from C++ via embedded Python, but I don't know how I can call computeResult from my Python code. I don't want to create a new process everytime I call computeResult, so I would have to access the existing instance of my C++ application.
Any ideas would be appreciated, even if they don't use embedded Python.