by joelgibson · 4y ago · 0 comments
x = x + y
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 x += y
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.No comments yet.