Skip to content

Lecture 10 — Higher-order functions and decorators

Thu 29 Oct 2026 · Boris Bolliet

TL;DR — A decorator is a function applied to a function at definition time. The wrapper it returns is a closure over the original.

Slides Notes Self-test

Demonstration files

File View Download Colab
lecture10-mine.ipynb Open in Colab
lecture10.ipynb Open in Colab

No new data in this lecture. The runs of experiments/cost.py and experiments/timing.py are synthetic (the chemostat-scale Lotka–Volterra model of models.CHEMOSTAT). experiments/fib_cache.py reads data/C9.csv, one of the ten chemostat runs of Blasius, Rudolf, Weithoff, Gaedke and Fussmann, Long-term cyclic persistence in an experimental predator-prey system, Nature 577, 226–230 (2020), data set on figshare doi:10.6084/m9.figshare.10045976 (CC BY 4.0), as cited in the lecture-4 demo.

Content

  1. Functions that take and return functions
  2. Decorators
  3. Counting and timing
  4. Caching

Exercises with solutions