I am integrating a c++ code with a python program. I have a python script that in loop waits for input. The problem is that I have to pass this input from a c++ program and read the result. I cannot use files! For every input I have to return a value to the c++ program without stopping the script. The python program must be running because in its initialization generates a data structure which I cannot build every time (quite expensive).
This is the python script prototype:
while (true):
input_string = input()
result = my_function(input_string)
return_result(result)
I have a simple function my_function which computes a result (string) and I have to return this result to the calling c++ program (through the function return_result).
I am looking for a solution specifically to send the input from a c++ program to a running python script for further processing.