Problem is when you have a shitty language like Python that does almost no optimisations so you're forced to write "clever" code if you want it to run reasonably fast.
If you must use Python, then pawn off the important work to C. Half of the reason this language exists for is easy FFI, and that's all the popular libraries get enough performance to be usable for non-toy applications.