The code below:
import numpy as np
x=np.array([1,-1,-1,1])
y = 0.5 * (x + 1)
id(x[0])==id(y[0])
The output is True, however if I assign a new value to x[0]=1212
, the output of
id(x[0])==id(y[0])
is also True. However the values of x[0]
and y[0]
is different. Why?