Published July 17, 2020 | Version v1

Providing Python Bindings For Complex and Feature-Rich C and C++ Libraries

Authors/Creators

  • 1. University of Graz

Description

Python is increasingly becoming the language of choice for a wide range of applications within the scientific community. For performance critical and high-performance computing (HPC) related tasks, however, it is still beneficial to develop critical code paths in a statically typed language like C or C++ and to then provide bindings to Python. In this talk, we present different options (e.g. ctypes, pybind11, cppyy) to provide these bindings, using both a simple demo library and SixTrackLib, an existing real-world high-performance C/C++ library as examples.

SixTrackLib in particular features multiple computing back-ends and a complex set of dependencies and configuration options which have to remain accessible to the users of the Python bindings. We compare the ease of use, support for modularity, and resulting performance across the different binding strategies. Moreover, we consider the interaction of the binding generation process with a build-system like CMake. We devote special attention to strategies and practices ensuring the consistent application of compiler options and sketch strategies for seamlessly performing library installations.

Files

PyHEP2020_MartinSchwinzerl.zip

Files (416.9 kB)

Name Size
md5:82b20e0a2124d7942aa4e41f8f336d22
416.9 kB Preview Download