If I add an array to another, Numpy appears to be making a copy of the original array:
>>> a = np.array([2,3])
...: b = a
...: a = a+np.array([1,1])
...: print a, b
[3 4] [2 3]
In contrast, if I use the +=
idiom, the original array appears to be changed in place.
>>> a = np.array([2,3])
...: b = a
...: a += np.array([1,1])
...: print a, b
[3 4] [3 4]
What is happening here? When are arrays changed in-place and when are they automatically copied?