|
|
|
|
|
by SandB0x
3424 days ago
|
|
> The performance of a "for loop" is usually dog slow (some special cases were optimized recently). You often spend hours figuring out how to vectorize your code so it runs decently fast. A similar story for Python and NumPy on this point, mitigated by NumPy's elegant broadcasting rules. Agree with everything else! |
|
Not as similar. When I was in grad school and encountered NumPy, I ported over my Matlab code to NumPy. It was hard to vectorize and so I had an explicit for loop (in both code bases).
NumPy ran 7x faster.
Did not really drill down to whether it was the loop itself or the operation in it, but I suspect it was the loop itself.
Matlab really has a slow for loop.