[Numpy-discussion] Ill-defined in-place operations (#1085)

Pauli Virtanen pav@iki...
Wed Apr 15 15:51:50 CDT 2009

Wed, 15 Apr 2009 22:34:49 +0200, Matthieu Brucher wrote:

> I think this is unavoidable. If we state clearly that every numpy
> function assums non-pointer aliasing, then people have to care about
> this themselves (like they would in Fortran, or in C++ for object-like
> arrays).

Nevertheless, this is an easy way to shoot yourself into foot. Also, (as 
indicated by the x.T example), it's doubtful anyone actually relies on 
the current behavior for N-D arrays, since it depends on order of data in 
memory, etc.

It rather likely is possible to cheaply detect potentially troublesome 
cases and raise a warning. (The user can silence these, if the behavior 
is really relied on.) I don't know what is the performance impact of 
Python warnings, though.

The alternative is to have really good documentation on views...

Pauli Virtanen

More information about the Numpy-discussion mailing list