[Numpy-discussion] Comparing x and x.view

Robert Kern robert.kern@gmail....
Wed Feb 7 22:05:46 CST 2007


Pierre GM wrote:
> On Wednesday 07 February 2007 22:38:30 Robert Kern wrote:
>> Pierre GM wrote:
>>> All,
>>>
>>> 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
>>> approach.
>> It isn't. Your analysis is correct.
> 
> So, there's no real point in using the Python 'id' function ?

Not for this purpose, no.

> Do we need a 
> shortcut to __array_interface__['data'] as id number ?

I'm not sure that would be useful. Different arrays may share the same starting
pointer but have different strides, and arrays may also have different starting
pointers but share some overlapping data.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list