Using Reflection to Generate C++ Python Bindings
Callum Piper
One of the issues often faced when writing Python bindings for C++ is the need to write excessive amounts of boilerplate code to bridge the gap between the C++ types and interfaces and their Python equivalents. Some libraries make this easier than others, but there is always overhead.
One of the easier and more commonly used libraries is PyBind11. This talk will explore how you can use Reflection in C++ to generate some of the necessary boilerplate code required when using PyBind11. We will present real-world examples that can be compiled using the latest experimental versions of compilers that support Reflection, and we'll also generate genuine, usable Python bindings. While these compilers are still under development, this will still highlight how the use of Reflection can simplify -- and abstract away -- the generation of some simple boilerplate code. We will also look at the limitations of such an approach and what we might aim for in the future.