Writing Python Bindings for C++ Libraries for Performance and Ease of Use – Saksham Sharma – CppNow



Writing Python Bindings for C++ Libraries for Performance and Ease of Use – Saksham Sharma – CppNow

Writing Python Bindings for C++ Libraries for Performance and Ease of Use - Saksham Sharma - CppNow

https://www.cppnow.org​
https://www.linkedin.com/company/cppnow

Writing Python Bindings for C++ Libraries for Performance and Ease of Use – Saksham Sharma – CppNow 2023
Slides: https://github.com/boostcon/cppnow_presentations_2023

The unix philosophy encourages writing small applications that compose well, and unix / linux / sh have provided us with nice chaining tools that let us achieve this. This works well enough, but chaining of processes makes it complicated to actually share memory space, library versions, and memory layouts of various objects. Working within a single programming language (Python for instance), we can script and keep local memory state and chain together things however we like. Think of numpy or pandas as examples.

In this talk we will discuss how we can use boost::python and friends to help us build our C++ libraries as dynamically linked libraries that can be exposed safely as python functions and objects in python programs. This will be done entirely in C++, with Python being the equivalent of a shell for us (helping us invoke our library’s methods).

We will use some real-world-inspired examples of libraries as case studies to explore how to design the user facing API for such software, and what kind of nuances to think about while doing so.

1. Managing memory to inter-op smoothly with Python, which is garbage collected
2. Inter-operability and conversion between C++ and python data containers
3. Handling multiple threads and background processing
4. Sharing data and pointers across modules
5. Ensuring build system consistency to avoid incompatibility across build environments
6. Some common API design ideas tried and tested in actual applications.

Saksham Sharma

Saksham Sharma works as a Quantitative Research Developer at Tower Research Capital LLC, a high frequency trading firm based out of New York. He develops low latency and high throughput trading systems and strategies used for the firm’s global quantitative trading. In addition, he also helps design and improve big data research infrastructure used for trading research using a combination of C++ and Python. Thanks to an urge to optimize his daily workflow, he also owns the build systems, tooling, and package managers for C++ within his team.

In the past, his interest lay in fields of program analysis research, functional programming, and systems security; but now he is a reformed geek (exemplified by a switch to VSCode after almost a decade with Emacs), and enjoys guitar, driving, badminton, and snowboarding.

Video Sponsors: think-cell and Bloomberg Engineering
Audience Audio Sponsors: Innoplex and Maryland Research Institute

Videos Filmed & Edited By Bash Films: https://bashfilms.com/
YouTube Channel Managed & Optimized By Digital Medium Ltd: https://events.digital-medium.co.uk

CppNow 2024
https://www.cppnow.org​
https://twitter.com/cppnow

#boost #cpp #python

Comments are closed.