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
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to