Using Reflection to Generate C++ Python Bindings
summary
Uses C++ Reflection (compiled against the experimental P2996 Clang fork) to auto-generate real Python bindings for C++ libraries with PyBind11, turning per-function and per-class boilerplate into a compile-time loop that binds functions, parameter names, enums and reflection-generated constructors. Examples compile and produce usable modules, noticeably reducing maintenance for large APIs, but the approach struggles with complex ownership semantics and annotation-driven custom behavior, so hand-written PyBind11 wrappers or a different binding strategy remain necessary for advanced cases.
AI-written summary · about
chapters (12)
- 0:00Reflection-based Python bindings
- 1:09P2996 reflection in Clang
- 2:33Boilerplate in PIBind 11
- 3:39Key reflection operators
- 5:07Reflecting namespaces
- 6:10Iterating namespace members
- 7:35Binding function parameters
- 8:39Reflecting and binding classes
- 10:08Binding constructors
- 11:33Binding member functions
- 12:15When reflection is most useful
- 13:39Limitations of reflection
related talks
29mGenerating Python bindings to C++ libraries
01h 02mWriting Python Bindings for C++ Libraries: Easy-to-use Performance
48mIntegrate Python and C++ with pybind11
49mOttergon: Modern Ways of Writing Bindings
05mPybind11 - Python on Steroids
01h 01mReflection
36mIntroduction to C++ python extensions and embedding Python in C++ Apps
25mHow to bring your C++ project to Python land
