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.
翻译:绑定 Python 和 C++ 具有不可否认的好处, 以利用两种语言的最佳功能。 这对HEP 和其他科学界尤其相关, 后者在 C++ 框架中投入了大量资金, 并正在迅速将其数据分析移到 Python 。 Awkward Array 版本 2, 是一个 Scikit- HEP Python 库, 介绍一套不依赖任何应用程序的 C++ 库。 用户可以直接将这些图书馆纳入它们的汇编, 而不是与平台特定图书馆连接。 这一新开发使得Awkward 的 Array 和其他科学界更容易融入其他项目, 因为这些项目的实施很容易从 Awkward Array 代码库的其余部分进行分解。 Awkward Array Pray Pyton Python 库并不包含使用 Awkward Arrupork 或 Pybind11 的参考文件。 C++Lus 用户可以使用它们进行阵列, 然后将它们复制到任何专门的数据类型 - 原始缓冲缓冲、 弦、 弦、弦、 和折叠、 将C+LOlick 的校正 的校正的校头的校的校正的校正的校的校对的校对的校对调。</s>