The Awkward World of Python and C++

03/03/2023
by   Manasvi Goyal, et al.
0

There are undeniable benefits of binding Python and C++ to take advantage of the best features of both languages. This is especially relevant to the HEP and other scientific communities that have invested heavily in the C++ frameworks and are rapidly moving their data analyses to Python. Version 2 of Awkward Array, a Scikit-HEP Python library, introduces a set of header-only C++ libraries that do not depend on any application binary interface. Users can directly include these libraries in their compilation rather than linking against platform-specific libraries. This new development makes the integration of Awkward Arrays into other projects easier and more portable as the implementation is easily separable from the rest of the Awkward Array codebase. The code is minimal, it does not include all of the code needed to use Awkward Arrays in Python, nor does it include references to Python or pybind11. The C++ users can use it to make arrays and then copy them to Python without any specialized data types - only raw buffers, strings, and integers. This C++ code also simplifies the process of just-in-time (JIT) compilation in ROOT. This implementation approach solves some of the drawbacks, like packaging projects where native dependencies can be challenging. In this paper, we demonstrate the technique to integrate C++ and Python by using a header-only approach. We also describe the implementation of a new LayoutBuilder and a GrowableBuffer. Furthermore, examples of wrapping the C++ data into Awkward Arrays and exposing Awkward Arrays to C++ without copying them are discussed.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/15/2020

Awkward Arrays in Python, C++, and Numba

The Awkward Array library has been an important tool for physics analysi...
research
02/20/2023

Awkward to RDataFrame and back

Awkward Arrays and RDataFrame provide two very different ways of perform...
research
06/18/2020

Array Programming with NumPy

Array programming provides a powerful, compact, expressive syntax for ac...
research
10/01/2020

Scipp: Scientific data handling with labeled multi-dimensional arrays for C++ and Python

Scipp is heavily inspired by the Python library xarray. It enriches raw ...
research
03/03/2023

Using a DSL to read ROOT TTrees faster in Uproot

Uproot reads ROOT TTrees using pure Python. For numerical and (singly) j...
research
06/28/2022

Improving Tese Case Generation for Python Native Libraries Through Constraints on Input Data Structures

Modern Python projects execute computational functions using native libr...
research
04/01/2021

Using Python for Model Inference in Deep Learning

Python has become the de-facto language for training deep neural network...

Please sign up or login with your details

Forgot password? Click here to reset