Konstantin Bespalov
How to implement convenient Python bindings to C++
#1about 4 minutes
The business case for Python bindings to a C++ library
A C++ financial pricing library required a Python interface for quantitative analysts to perform research and development.
#2about 2 minutes
Evaluating an initial approach using .NET integration
The first attempt used a .NET assembly with pythonnet, but it suffered from poor performance and a lack of IDE support.
#3about 4 minutes
Choosing pybind11 for direct C++ to Python bindings
Pybind11 was selected over the Python/C API for its ability to minimize boilerplate code when creating direct C++ bindings.
#4about 2 minutes
Identifying usability gaps in the initial pybind11 bindings
The initial pybind11 implementation still lacked crucial features like type hints, Pythonic collections, and pickling support for multiprocessing.
#5about 2 minutes
Adding IDE support and type hints with stub files
PEP 484 and .pyi stub files provide a type interface for the C++ extension module, enabling autocompletion and navigation in IDEs.
#6about 2 minutes
Creating a Pythonic API with variants and magic methods
Using std::variant simplifies function arguments and implementing magic methods like __iter__ makes C++ collections behave like native Python ones.
#7about 1 minute
Enabling multiprocessing with custom pickling support
The copy_reg module is used to register custom serialization and deserialization functions, making C++ objects picklable for multiprocessing.
#8about 1 minute
Summarizing the solution and using code generation
The final solution combines pybind11 with several enhancements, and a code generator is recommended to maintain the bindings for large projects.
#9about 2 minutes
Q&A on exceptions, SWIG, and code generation tooling
The speaker answers audience questions about propagating C++ exceptions, comparing pybind11 to SWIG, and the specific code generator used.
Related jobs
Jobs that call for the skills explored in this talk.
envelio
Köln, Germany
Remote
Senior
Python
Software Architecture
Matching moments
04:09 MIN
How Python became the dominant language for AI
AI in the Open and in Browsers - Tarek Ziadé
02:49 MIN
Using AI to overcome challenges in systems programming
AI in the Open and in Browsers - Tarek Ziadé
06:28 MIN
Using AI agents to modernize legacy COBOL systems
Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3
14:14 MIN
Scripting presentations and demos in VS Code
Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3
01:53 MIN
The role of a freelancer integrated within a team
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
03:17 MIN
Selecting strategic partners and essential event tools
Cat Herding with Lions and Tigers - Christian Heilmann
03:45 MIN
Preventing exposed API keys in AI-assisted development
Slopquatting, API Keys, Fun with Fonts, Recruiters vs AI and more - The Best of LIVE 2025 - Part 2
04:09 MIN
The emerging market for fixing AI-generated code
Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3
Featured Partners
Related Videos
CUDA in Python
Andy Terrel
The best of both worlds: Combining Python and Kotlin for Machine Learning
Nils Kasseckert
Python-Based Data Streaming Pipelines Within Minutes
Bobur Umurzokov
Python: Behind the Scenes
Diana Gastrin
101 brilliant things of C++
Andreas Fertig
C++ in constrained environments
Bjarne Stroustrup
Designing gRPC APIs - The things they don't tell you
Bastian Eicher
Full Stack Web Apps With Nothing But Python
Eli Holderness
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.

Patronus Group
Berlin, Germany
Senior
Kotlin
Spring Boot
Amazon Web Services (AWS)

Dennemeyer Group
Hesperange, Luxembourg
Intermediate
Senior
.NET
Structured Query Language (SQL)

zeb consulting
Frankfurt am Main, Germany
Junior
Intermediate
HTML
React
JavaScript

Citigroup Inc.
Charing Cross, United Kingdom
Remote
Senior
API
C++
Azure
Kafka
+6

Vertus Partners
Charing Cross, United Kingdom
£70-110K
Java
DevOps
Python

Clerkenwell
Charing Cross, United Kingdom
Senior
R
Python
Grafana
Data analysis
Machine Learning

PROCITEC GmbH
Pforzheim, Germany
Remote
QT
C++
GIT
CMake
+8

Squarepoint Capital
Charing Cross, United Kingdom
Intermediate
API
C++
Python
PostgreSQL
Amazon Web Services (AWS)
