Improve performance
- Find the slowest thing in the profile, and try to speed it up.
- Isolate the problem in a function.
- Make a minimal snippet of code that recreates the slowness
- Write a few tests as the easiest way to make code faster is to make it incorrect.
- Run this snippet multiple times as you try out possible improvements.