4 ms·
> Many times I have had to decide if my Python code would be more legible or get free performance. This is rarely an option that has presented itself to me. If
by nodja 4y ago
> Many times I have had to decide if my Python code would be more legible or get free performance.
This is rarely an option that has presented itself to me. If there's a clear performance issue in my code then I probably picked the wrong algorithm or my code has a bug, unless you decided for some reason to do heavy calculations in raw python. If you're doing operations on big chunks of data you should always use something like numpy or jax.
Even OPs issue the clear reason is that it's doing an operation in place instead of creating a copy, for ML models this can only be done at inference time and not training time since you need to keep track of the whole network, hence why the code was in it's unoptimized state.