[Numpy-discussion] Ravel and inplace modification

Gael Varoquaux gael.varoquaux@normalesup....
Thu Mar 20 07:04:25 CDT 2008

At the nipy sprint in Paris, we have been having a discussion about
methods modifying inplace and returning a view, or returning a copy.

The main issue is with ravel that tries to keep a view, but that
obviously has to do a copy sometimes. (Is ravel the only place where this
behavior can happen ?). We came up with the following scenario:

Mrs Jane is an experienced Python developper, working with less
experienced developpers. She has developped a set of functions to process
data that assume they can use the ravel method returning a view. One day
another programmes feeds it new kind of data. The functions work, but
return something wrong.

We (Stefan van der Walt, Matthew Brett and I) are suggesting that it
would be a good idea to add a keyword to the ravel method so that it
raises an exception if it cannot return a view. Stefan is proposing to
implement it.

What do people think about this? Should Stefan go ahead?



More information about the Numpy-discussion mailing list