Python Aliasing Arrays
If 'a' is an array, we can assign it to 'b', as:
This is a simple assignment that does not make any new copy of the array 'a'. It means, 'b' is not a new array and memory is not allocated to 'b'. Also, elements from 'a' are not copied into 'b' since there is no memory for 'b'. Then how to understand this assignment statement? We should understand that we are giving a new name 'b' to the same array referred by 'a'. It means the names 'a' and 'b' are referencing same array. This is called 'aliasing '.
'Aliasing' is not 'copying' . Aliasing means giving another name to the existing object. Hence, any modifications to the alias object will reflect in the existing object and vice versa.
alias array example:
from numpy import * a = arange(1, 6) b = a print('Original array:', a) print('Alias array:', b) b=99 print('After modification:') print('Original array:', a) print('Alias array:', b)