Skip to main content
eScholarship
Open Access Publications from the University of California

Reflection-Based Python-C++ Bindings

  • Author(s): Generowicz, Jacek
  • Lavrijsen, Wim T.L.P.
  • Marino, Massimo
  • Mato, Pere
  • et al.
Abstract

Python is a flexible, powerful, high-level language with excellent interactive and introspective capabilities and a very clean syntax. As such, it can be a very effective tool for driving physics analysis. Python is designed to be extensible in low-level C-like languages, and its use as a scientific steering language has become quite widespread. To this end, existing and custom-written C or C++ libraries are bound to the Python environment as so-called extension modules. A number of tools for easing the process of creating such bindings exist, such as SWIG and Boost. Python. Yet, the process still requires a considerable amount of effort and expertise. The C++ language has few built-in introspective capabilities, but tools such as LCGDict and CINT add this by providing so-called dictionaries: libraries that contain information about the names, entry points, argument types, etc. of other libraries. There flection information from these dictionaries can be used for the creation of bindings and so the process can be fully automated, as dictionaries are already provided for many end-user libraries for other purposes, such as object persistency. PyLCGDict is a Python extension module that uses LCG dictionaries, as PyROOT uses CINT reflection information, to allow \cwPython users to access C++ libraries with essentially no preparation on the users' behalf. In addition, and in a similar way, PyROOT gives ROOT users access to Python libraries.

Main Content
Current View