Reputation: 147
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.
Upvotes: 1
Views: 287
Reputation: 147
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.
Upvotes: 1