I need to code some functionality in Python 3.8 and comply to a given C++ Interface. The code should replace an existing .so
file which exposes this interface that is defined in a C++ header.
Here's the two options I considered so far:
.so
file by coding it in C++ including the interface header and delegating each call to Python with PyEval_CallObject(...)
.so
from a .pyx
trying to export the needed symbolsOption 1 would most probably work, but seems a lot of work for a dumb wrapper. There must be a better way. I couldn't get option 2 to work, and I don't know if that's possible at all.
Happy to hear about any other ideas and hints.
In the end I picked 1. as the solution but using a nice library called pybind11
( https://github.com/pybind/pybind11 ). It really simplifies both interfacing Python from c++ and c++ from Python especially when it comes to type conversions. In this way the wrapper .so
file became really small.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.