a=np.array([[1,2],[4,5]])
b=a.T
print(a is b)
print(np.shares_memory(a,b))
for i in a:
for j in I:
print(i,j,id(j))
print('************')
for i in b:
for j in I:
print(i,j,id(j))
The output of the above code is
False
True
[1 2] 1 2027214431408
[1 2] 2 2027214431184
[4 5] 4 2027214431408
[4 5] 5 2027214431184
************
[1 4] 1 2027214431632
[1 4] 4 2027214431184
[2 5] 2 2027214431632
[2 5] 5 2027214431184
My question is why the location of alternate integer objects are the same in the above code. As python initializes different memory locations to each different objects