Re:Speedup from switch to +=
by joelgibson on Monday September 12, 2022 @02:31AM
(#32806734)
This change isn't a matter of Python being slower than a compiled language, it's changing the meaning of the code. The line
creates a copy of the array x, adds y to it, and then sets the variable x to that new array. In contrast, the line
adds the array y in-place into the array x (and so hopefully no other piece of code is relying on x being immutable). This kind of trade-off occurs in pretty much all programming, for instance you see it whenever big-integer libraries are used in C++ or Rust.
[ Parent
| on HN ]
There are no comments on this comment yet.