In [ ]:
%load_ext load_style
%load_style talk.css

Performance tools

...Making Python fast...

Traditional Python performance

  • Python has a number of strikes against it from a performance perspective
    • Dynamic typing
    • Intepreted
    • Extremely general object model
  • There is a long history of projects that have sought to make Python fast
    • SWIG (call C/C++ from Python)
    • f2py (call Fortran from Python)
    • ctypes (call shared libraries from Python)
    • Boost.Python (call C++ from Python)

New tools for performance

  • New breed of tools are emerging
    • Just in time (JIT) compilation
    • LLVM
    • Optimization techniques
    • Add static types and type inference to Python
  • In this talk:
    • Cython
    • Numba
  • Others

Cython

  • Superset of Python that adds explicit static typing
  • Can also call C/C++ code
  • Compiled into fast C/C++ with autogenerated Python bindings
  • Established, robust, stable
  • Best solution for wrapping existing C/C++ codes
  • Solid support for multidimensional numerical arrays
  • Open source, community effort
  • The GitHub project page

Numba

  • Start with regular Python code
  • Parses the Python code into its abstract syntax tree (AST)
  • Static typing and type inference
  • Uses LLVM to JIT compile directly into machine code
  • New, but gaining momentum
  • Solid support for multidimensional numerical arrays
  • The GitHub project page
  • Open source, developed primarily by Continuum Analytics

Performance benchmarks!