Invasive procedures: Python affordances for performance measurement
When your Python code is too slow, you need to identify the bottleneck that’s causing it: you need to understand what your code is doing. Luckily, beyond pre-existing profiling tools, there are also a variety of ways you can poke and prod Python programs to get a better understanding of what they’re doing internally.
Source: Invasive procedures: Python affordances for performance measurement, an article by Itamar Turner-Trauring.