Live data from Hacker News

Cppyy – Automatic Python-C++ bindings

cppyy.readthedocs.io

21–25 of 25 posts

Re: Cppyy – Automatic Python-C++ bindings

#21

I need to create Python bindings for a C++ library and after a brief survey of the available options was planning on using SWIG ( http://www.swig.org/tutorial.html ). How does this compare?

Use pybind11 super easy to get startet with and reasonably easy to automate with libclang if your C++ API is simple.

Re: Cppyy – Automatic Python-C++ bindings

#22

This is super interesting but if I am looking to bring C++ into my Python code base it would be because performance is important enough to do so. With that in mind I am not sure how this stacks up against compiled half steps like Cython or foreign function interfaces likes ctypes or CFFI instead.

If you have a Python code base and are looking to speed up some part of it, Cython is the way to go. Pybind11 and cppyy are more for cases where you have a bunch of C++ code that you want to provide a Python interface for.

Cython unfortunately doesn't have a very good pypy story, which cppyy does.

Re: Cppyy – Automatic Python-C++ bindings

#25
post #6

How does this compare to pybind11?

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?
Post reply on HN