Hacker News new | ask | show | jobs
by adenner 2604 days ago
How does this compare to pybind11?
1 comments

If you have a C++ project, you want to have Python bindings, and you don't want to share your header files, pybind11 is the way to go.

If you want to / can share your header files, cppyy is a very convenient way of being able to call your C++ code from Python. I'm not sure if there is a way to use it without headers.

One thing I wanted to do for a project at work is to add python bindings to our c++ library, having the least effort for having a decent python binding. Two features I am looking for are support for return values of custom objects of arbitrary size and c++ exceptions raising python exceptions. Cppyy seems to support these, do you know if/how they work on pybind11?
How do you link any cpp binary without headers without guessing the calling convention?
It's not so much that you never have the headers... more that you don't always want to provide the headers to everyone (since they may contain things you don't want to share.)

I looked into it a bit further, and cppyy does have provisions for this: https://cppyy.readthedocs.io/en/latest/bindings_generation.h...

I may have misread that page, but it looks like you can create a .rootmap and .pcm file and distribute that instead of the C++ headers.