You are here


How to use ROOT with PyPython (PyPyROOT) 

PyPy ( offers a highly compatible version of the Python 2.7 interpreter and comes with a just-in-time compiler (JIT) that can greatly speed up certain types of computing tasks. In particular, mathematics done in loops, as is common in HEP analysis codes.

Where PyPy breaks compatibility, is in the use of extension libraries, especially when those rely on the internals of the CPython interpreter. PyROOT being on of them, it did so far not work on PyPy.

Now, a first beta release of PyPy supporting PyROOT is available here:


Run the setup script (which sets up the proper CPython, ROOT, and GCC):


which will make the executable 'pypyroot' available, which can be used as the normal CPython Python interpreter. For example:

$ pypyroot>>>> import ROOT
>>>> c1 = ROOT.TCanvas()
>>>> # etc.

I hope to collect feedback over a period of about a month or so, then cut a release 1.0 by CHEP. Please help out by trying it out!

Short-list of known incompatibilities with PyROOT 

Compatibility with PyROOT is not 100%, and in some ways never will be. For example the fact that PyPy uses a garbage collector rather than reference counting, and that "from ROOT import *" can not work together with the JIT. However, both these can simply be worked around to have code that works fine on both interpreters (e.g. consistently use "import ROOT") and the list of remaining features to-be-done is rather small and shrinking:

  • TPython does not work as currently build (this also means that the tutorial does not run, even as individual tutorials do)
  • The same then also goes for callbacks, such as for TF1/2/3 and TPySelector
  • PyCintex not supported (as it loads
  • No pass-by-reference of builtin types (such as ROOT.Double and ROOT.Long)
  • No memory heuristics or GIL release
  • C++ exceptions are not caught and translated Python exceptions
  • No "from ROOT import *" with lazy loading/creation

It is trivially possible to determine whether code is run from PyPy or from CPython, by attempting to import __pypy__, like so:

      import __pypy__
      # PyPy specific stuff goes here (PyPyROOT)
except ImportError:
     # CPython specific stuff goes here (PyROOT)

Supported C++ feature set

The underlying basis of PyPyROOT is the cppyy module of PyPy (enabled by default since release 2.0). Although the version shipped with PyPy is based on Reflex rather than CINT, the supported C++ feature set is the same and can be found here:

Future with ROOT6 

When ROOT6 comes out, the CINT backend of PyPyROOT (or cppyy, rather) is ready to be swapped out for a Cling backend. The latter allows for a tighter integration with the JIT (as has been shown with the Reflex backend, which is part of PyPy by default since release 2.0).