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.
Senior Backend Engineer Electrical Engineering
envelio
Köln, Germany
Remote
Senior
Python
Software Architecture
Matching moments
23:07 MIN
Proposing new patterns for enterprise Python development
Enterprise Python: Software That Lives Long And Prosper
14:53 MIN
Accelerating language support with numba-cuda and nupack
CUDA in Python
13:40 MIN
Navigating language-specific binding challenges
How AWS Generates Polyglot Libraries Based on a Single TypeScript Codebase
28:27 MIN
A progressive approach to programming GPUs in Python
Accelerating Python on GPUs
17:39 MIN
Leveraging vernacular developers for faster innovation
Enterprise Python: Software That Lives Long And Prosper
06:33 MIN
Adopting a philosophy of configuration without configuration files
Automagic Configuration in Python
30:10 MIN
Overcoming challenges in automotive software deployment
Intelligent Data Selection for Continual Learning of AI Functions
36:33 MIN
Key benefits of using Python-native streaming frameworks
Python-Based Data Streaming Pipelines Within Minutes
Featured Partners
Related Videos
CUDA in Python
Andy Terrel
Python: Behind the Scenes
Diana Gastrin
The best of both worlds: Combining Python and Kotlin for Machine Learning
Nils Kasseckert
Python-Based Data Streaming Pipelines Within Minutes
Bobur Umurzokov
Enjoying SQL data pipelines with dbt
Matthias Niehoff
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
Related Articles
View all articles



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

Senior Python Software Entwickler (m/w/d) Google Cloud
SOURCE GmbH
Wiesbaden, Germany
€65-75K
Senior
Python

Software Developer with C++ , Python Financial
NextGen Staffing
Charing Cross, United Kingdom
Remote
£35-40K
Intermediate
C
C++
JIRA
+3

Senior Software Engineer - C++, Python - Financial/Banking
N.P.A.
Charing Cross, United Kingdom
£85-120K
Senior
C++
JIRA
Linux
Python
+2

Python / C++ Software Engineer
Capital Group
Paris, France
Intermediate
C++
Python
Pandas
Machine Learning
Amazon Web Services (AWS)

Software Engineer C++/Python
Autobrains AI Technologies GmbH
Berlin, Germany
Intermediate
C++
Python
Docker
Jenkins
Continuous Integration

Python Softwareentwickler mit mathematisch-naturwissenschaftlichem Schwerpunkt
IKB Deutsche Industriebank AG
Düsseldorf, Germany
Remote
GIT
JIRA
Azure
Python
+2

Senior Software Engineer / Developer with C++ , Python Financial /Trade
NextGen Staffing
Charing Cross, United Kingdom
Remote
£35-40K
Senior
C
C++
JIRA
+3

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

Embedded Software Engineer - C++ / Python
Brunel GmbH
Bremen, Germany
C++
Python
Unit Testing
Software Architecture