[Numpy-discussion] Checking for views (was: Should arr.diagonal() return a copy or aview?)

Larsen, Brian A balarsen at lanl.gov
Thu May 24 13:07:37 EDT 2012

This is the stack overflow discussion mentioned.


I basically implemented the answer from SO.  I feel like the "is" gives you a good handle on things since to be true they are actually the same location in memory.


On May 24, 2012, at 8:56 AM, Jonathan T. Niehof wrote:

On 05/23/2012 05:31 PM, T J wrote:

It seems that there are a number of ways to check if an array is a view.
Do we have a preferred way in the API that is guaranteed to stay
available? Or are all of the various methods "here to stay"?

We've settled on checking array.base, which I think was the outcome of a
stackoverflow thread that I can't dig up. (I'll check with the guy who
wrote the code.)

Jonathan Niehof
ISR-3 Space Data Systems
Los Alamos National Laboratory
Los Alamos, NM 87545

Phone: 505-667-9595
email: jniehof at lanl.gov<mailto:jniehof at lanl.gov>

Correspondence /
Technical data or Software Publicly Available
NumPy-Discussion mailing list
NumPy-Discussion at scipy.org<mailto:NumPy-Discussion at scipy.org>


Brian A. Larsen
ISR-1 Space Science and Applications
Los Alamos National Laboratory
PO Box 1663, MS-D466
Los Alamos, NM 87545

(For overnight add:
SM-30, Bikini Atoll Road)

Phone: 505-665-7691
Fax:   505-665-7395
email: balarsen at lanl.gov<mailto:balarsen at lanl.gov>

Correspondence /
Technical data or Software Publicly Available

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120524/c62a10b7/attachment.html>

More information about the NumPy-Discussion mailing list