[Numpy-discussion] Response to PEP suggestions
oliphant at ee.byu.edu
Thu Feb 17 21:26:13 EST 2005
> Ick, that's horrible. Functions that sometimes copy and sometimes
> don't are generally bad news IMO. This is just a way to introduce
> nasty, invisible bugs. The exceptions are things like asarray that are
> explicit about their variable behaviour.
> I'd be much happier if flat never made copies, but always worked by
> some sort of deep juju, while ravel always made copies.
I tend to agree (though) there is precedence for "return a copy only if
you have to" at least on the C-level.
What I suggest is that attributes never return copies while methods
return copies when necessary.
In that vein, I am proposing making X.flat an array iterator and
allowing array iterators to be indexed and set as if they were 1-d
arrays with the underlying array being changed. This is actually an
easy change with the current code base. Will it break any code?
There maybe some X.flats that need to be changed to ravel. But it seems
like a really good idea.
More information about the NumPy-Discussion