Writing Python Bindings for C++ Libraries: Easy-to-use Performance
Talkat CppCon 2023 · on Friday, 2023-10-06· at 13:30· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Shows how C++ libraries compile into Python extension modules via the CPython C API and compares pybind11 boost::python and Cython implementations with microbenchmarks (pure CPython call ~67 ns CPython C API ~74 ns pybind11 slower boost slightly slower). Builds a file-reader API that uses return-internal lifetime handling, Vector indexing suites, GIL release for parallel readers, and capsules to cache C function pointers (micro-optimization saves ~300 ns per hot call). Produces working examples, discusses exception costs and Wheels distribution.
AI-written summary · about
chapters (14)
- 0:00Python bindings for C++ intro
- 3:57Combining Python and C++
- 9:57Python extension modules
- 13:33Binding libraries benchmarks
- 16:23Clean Python APIs for C++
- 21:01Custom binary format reader
- 27:19Object lifetimes and references
- 31:57Exceptions and threading
- 34:26Multi-threaded HTTP server
- 40:43Optimizing hot loops
- 47:08NumPy/Pandas lessons
- 53:13Choosing binding library
- 58:39Distribution and user experience
- 1:00:02Type annotations
related talks
29mGenerating Python bindings to C++ libraries
01h 21mAccelerating Python With C++
25mHow to bring your C++ project to Python land
15mUsing Reflection to Generate C++ Python Bindings
25m"Boosting Python Numeric Computations with Dynamic C++ Integration"
49mOttergon: Modern Ways of Writing Bindings
29mC++ ♥ Python: from modules to hybrid applications
36mIntroduction to C++ python extensions and embedding Python in C++ Apps
