How to Find the Slow Part of Your Python Code (Without Guessing)
Almost everyone optimises the wrong thing. Measure with cProfile and timeit instead, learn to read the output, and use the two facts that explain most slow Python: membership tests that are O(n) inside a loop, and Amdahl's law, which caps how much any one fix can buy you.