Python 與 C/C++ 之間互相溝通的方式:
1. pybind11 - Seamless operability between C++11 and Python
1.1 export C/C++ functions to Python2. Cython - C-Extensions for Python把 C code compile 成 shared libray, 讓 Python 可以 import 這個 module.1.2 export Python functions to C/C++
A simple example of exporting a C function which is invoked in Python.把 Python interpreter embed 在 C program, 並且能夠在 C code 裡 import Python modules.Source code repositories of pybind11.
A simple example of exporting a Python function which is invoked in C.
Cython 是一種 programming language, 是 Python 的 superset.3. ctypes - A foreign function library for Python
Cython code 需要先被 compile 成 C code,然後再以 C compiler 產生 shared librarry。
2.1 export C/C++ functions to PythonTutorial: Calling C functions.2.2 export Python functions to C/C++Tutorial: Embedding Cython modules in C/C++ applications.Source code repositories of Cython.
透過 ctypes,可以在 Python 裡 import C/C++ shared libraries.4. Python/C API
Extending and Embedding the Python Interpreter.5. gRPC - A high-performance, open source universal RPC framework