29 Dec
2018
29 Dec
'18
4:16 p.m.
Hi Sebastian. I don't have an opinion (yet) about this matter, but I have a question: On Thu, Dec 27, 2018 at 12:30 AM Sebastian Berg wrote: [...]
new_arr = arr.reshape(new_shape) assert np.may_share_memory(arr, new_arr)
# Which is sometimes -- but should not be -- written as: arr.shape = new_shape # unnecessary container modification
[...] Why is this discouraged? Why do you call this "unnecessary container modification"? I've used this idiom in the past for exactly those cases where I wanted to make sure no copy is made. And if we are not supposed to assign to arr.shape, why is it allowed in the first place? cheers, Matthias