[Numpy-discussion] Comparing x and x.view

Pierre GM pgmdevlist@gmail....
Wed Feb 7 21:00:28 CST 2007


I want to compare whether two arrays point to the same data.
I've been using 'is' so far, but I'm wondering whether it's the right 

If x is a plain ndarray,  `x is x`, and `x is not x.view()`. I understand the 
second one (I think so...), `x` and `x.view `are two different Python 
objects. However, `x.__array_interface__ == x.view().__array_interface__`, 
which means that the underlying memory hasn't been modified at all, right ? 
In other terms, the data hasn't been copied, it's just being accessed 
slightly differently.

So, when I'm using `x is y` to test whether some data has been copied, I 
should in fact compare the __array_interface__s, shouldn't I ?

Sorry for the poor phrasing, and thanks a lot for your forthcoming inputs.


More information about the Numpy-discussion mailing list