[SciPy-user] SciPy-user Digest, Vol 29, Issue 11
Fernando.Perez at colorado.edu
Fri Jan 6 16:39:23 CST 2006
Travis Oliphant wrote:
> Ultimately this is because you can't tell whether you simply have
> b = a # We really could resize a because b is just another name for a...
> or this
> b = a[1:5:2,0:3:2] # now b is a *view* of a's memory. If we resize a,
> then b is really going to be messed up and give us problems.
> We could distinguish these two using another array flag like (SHAREDATA)
> or something.
I'm not sure that can work in python:
In : a = N.arange(10)
In : b = a[::2]
a.SHAREDATA is now true
In : del b
a.SHAREDATA is still true, but shouldn't.
There is no way, to my knowledge, of enforcing this correctly. In a sense,
SHAREDATA would be a reference counting mechanism for numpy arrays, but Python
doesn't really give you enough low-level access to do this reliably (remember
that __del__ methods of objects are NOT guaranteed to run, so even that is not
More information about the SciPy-user