[Numpy-discussion] How to detect ndarrays pointing to the same memory?
Fri Jul 17 09:30:38 CDT 2009
I have a simple question: How can I detect whether two arrays share the same
>>> a = numpy.arange(10)
>>> b = a.view(numpy.ndarray)
>>> a is not b # False, as expected
>>> a.data is b.data # I expected this to be True
<read-write buffer for 0x8a6920, size 80, offset 0 at 0x7fad2536c4b0>
>>> b.data # even the memory addresses differ?!
<read-write buffer for 0x894810, size 80, offset 0 at 0x7fad2536c4f0>
>>> a.data = "\x55"
>>> b.data == "\x55" # yes, the buffers point to the same data
More information about the NumPy-Discussion