Consider the multiple assignment x[0],y = y,x[0]
. Applied to each of the four below cases, this gives four different results.
Case 1:
x = [[1,2], [3,4]] y = [5,6]
gives
x = [[5,6], [3,4]] y = [1,2]
Case 2:
x = np.array([[1,2], [3,4]]) y = [5,6]
gives
x = array([[5,6], [3,4]]) y = array([5,6])
Case 3:
x = [[1,2], [3,4]] y = np.array([5,6])
gives
x = [array([5,6]), [3,4]] y = [1,2]
Case 4:
x = np.array([[1,2], [3,4]]) y = np.array([5,6])
gives
x = array([[5,6], [3,4]]) y = array([5,6])
It appears that the multiple assignment of lists is smarter (going through a temporary variable automatically) than the multiple assignment of Numpy arrays.
Thoughts?
EDIT: It is not smarter afterall...