Performant Python

Numba

Overview:

  • Teaching: 5 min
  • Exercises: 15 min

Questions

  • What is numba?
  • When and how can I use it to improve my code?

Objectives

  • Know that you can use numba to improve the performance of your code with just in time compilation
  • Understand that numba likes, loops and numpy

Numba resources

As with Scipy a large number of resources are available to help you work with numba including a 5 minute introduction.

Explore this in a new notebook and then revisit our $\pi$ calculators from earlier and see if you can use numba to improve their performance, what effect does it have in these cases.

Our Now code mandelbrot example has the opportunity to use numba effectively?

Alternatively try using numba with your existing

Key Points:

  • Numba uses simple decorators to perform just in time compilation, wcich can deliver signficant performance improvements 1-2 orders of magnitude.