Skip to content

Why you should write tools with PyLOOS

Grossfield Lab edited this page Dec 30, 2019 · 3 revisions

Although LOOS is at its heart a C++ library, we highly recommend doing most if not all new tool development using the Python layer. While Python is intrinsically slower than C++, in our experience the performance difference falls into 2 domains:

  • jobs that run fast (a few seconds) may be 2x slower in python, but you don't care, because it's fast enough to be irrelevant
  • jobs that are expensive (minutes to hours), where the python layer costs you an additional 20-30%, because most of the work is done inside the C++ library anyway.

The classes and syntax are virtually the same regardless of whether you're using the C++ layer or the Python layer, so the main loop for the code you write will look very similar regardless. The advantage comes with the rest of the code -- amount of code required to handle I/O, file wrangling, etc, is much smaller with Python. Moreover, it's much easier to pull in other functionality, particularly if it's implemented as part of scipy; see this page for a discussion of how to switch back and forth between LOOS coordinates and numpy arrays.

See the second half of the LOOS talk slides for a description of how to develop using LOOS.