When you need to speed up your code or understand where a bottleneck is, profiling is one of the most effective techniques.
The Python standard library provides a built-in profiler that traces the execution and timing for each function and allows you to spot the functions that are more expensive or that run too many times, consuming most of the execution time.