C ++< - > Python:双向通信

时间:2016-08-11 14:35:29

标签: python c++ embedded-language

我想将Python应用程序集成到我的C ++应用程序中。通信必须是双向的,如以下示例所示:

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)

我考虑过通过嵌入式Python从C ++调用Python代码,但我不知道如何从Python代码调用computeResult。每次调用computeResult时我都不想创建新进程,所以我必须访问我的C ++应用程序的现有实例。

任何想法都会受到赞赏,即使他们不使用嵌入式Python。

0 个答案:

没有答案
相关问题