Inspired by my discussion with @charris in #9810, I would like to propose adding an optional copy argument to np.reshape() and ndarray.reshape().
Proposed semantics:
copy=None: copy only if necessary (default).
copy=True: always copy.
copy=False: never copy. Raise an error if the data cannot be reshaped without a copy.
This would allow users to ensure desired behavior for reshape and alleviate the primary use case for modifying ndarray.shape.
Inspired by my discussion with @charris in #9810, I would like to propose adding an optional
copyargument tonp.reshape()andndarray.reshape().Proposed semantics:
copy=None: copy only if necessary (default).copy=True: always copy.copy=False: never copy. Raise an error if the data cannot be reshaped without a copy.This would allow users to ensure desired behavior for
reshapeand alleviate the primary use case for modifyingndarray.shape.