My impression is that in NumPy, two arrays can share the same memory. Take the following example:
import numpy as np
a=np.arange(27)
b=a.reshape((3,3,3))
a[0]=5000
print (b[0,0,0]) #5000
#Some tests:
a.data is b.data #False
a.data == b.data #True
c=np.arange(27)
c[0]=5000
a.data == c.data #True ( Same data, not same memory storage ), False positive
So clearly b didn't make a copy of a; it just created some new meta-data and attached it to the same memory buffer that a is using. Is there a way to check if two arrays reference the same memory buffer?
My first impression was to use a.data is b.data, but that returns false. I can do a.data == b.data which returns True, but I don't think that checks to make sure a and b share the same memory buffer, only that the block of memory referenced by a and the one referenced by b have the same bytes.

numpy.may_share_memory(other than the built-inhelp), I thought there might be something else -- e.g.numpy.uses_same_memory_exactly. (my use case is slightly less general than the other one, so I thought there might be a more definitive answer). Anyway, having seen your name on a few numpy mailing lists, I'm guessing that the answer is "there is no such function".numpy.may_share_memory()does not show up in the reference manual only due to an accident of the organization of the reference manual. It's the right thing to use. Unfortunately, there is nouses_same_memory_exactly()function at the moment. To implement such a function requires solving a bounded linear Diophantine equation, an NP-hard problem. The problem size is usually not too large, but just writing down the algorithm is annoying, so it hasn't been done yet. If we do, it will be incorporated intonumpy.may_share_memory(), so that's what I recommend using.np.may_share_memory(). I use this mostly for debugging/optimization to make sure that I don't gratuitously allocate arrays by accident. Thanks again.