[Numpy-discussion] copy on demand
perry at stsci.edu
Fri Jun 14 12:19:05 EDT 2002
<Konrad Hinsen writes>:
<Perry Greenfield writes>:
> > I didn't mean to imply it wasn't possible, but that it was not
> > quite as clean. The thing I don't like about this approach (or
> > Paul's suggestion of a.sub) is the creation of an odd object
> > that has as its only purpose being sliced. (Even worse, in my
> Not necessarily. We could decide that
> is a view of the full array object, and that slicing views returns
> > opinion, is making it a different kind of array where slicing
> > behaves differently. That will lead to the problem we have
> > discussed for other kinds of array behavior, namely, how do
> A view could be a different type of object, even though much of the
> implementation would be shared with arrays. This would help to
> reduce confusion.
I'd be strongly against this. This has the same problem that other
customized array objects have (whether regarding slicing behavior,
operators, coercion...). In particular, it is clear which kind it
is when you create it, but you may pass it to a module that
presumes different array behavior. Having different kind of arrays
floating around just seems like an invitation for confusion. I'm
very much in favor of picking one or the other behaviors and then
making some means of explicitly getting the other behavior.
> > behavior). That could lead to confusion as well. Many may be
> > under the impression that x = a.view makes x refer to an array
> > when it doesn't. Users would need to know that a.view without
> > a '[' is usually an error.
> Why? It would be a full-size view, which might actually be useful
> in many situations.
But one can do that simply by
x = a
(Though there is the issue that one could do the following which is
not the same:
x = a.view
x.shape = (2,50)
so that x is a full array view with a different shape than a)
I understand the backward compatibilty issue here, but it is clear that
this is an issue that appears to be impossible to get a consensus on.
There appear to be significant factions that care passionately about
copy vs view and no matter what decision is made many will be unhappy.
More information about the NumPy-Discussion