by applecoffeecake · 1mo ago · 0 comments
The worst thing about Python is the loop phobia and emphasis on vectorization and slick one-liners. There's more to numerical algorithms than matmuls and pointwise nonlinearities. The problem is not only that most nontrivial algorithms don't vectorize easily if at all, but that nothing intellectually is gained by forcing the user to waste energy contorting what they already understand as a for loop into a slick one-liner only for that one-liner to be implemented under the hood as the loop that the user had in mind in the first place.
There are two further ironies here. The first is that writing something as a loop is typically the first step towards understanding and controlling sequential dependencies and parallelizability. In effect, Python is forcing you to do in your head what a C compiler already does! You might as well be writing C. The second is that parallel hardware is itself described in HDL by spatial for loops with explicit indexing, because indices are the clearest way to express connections and dependencies.
No comments yet.