I would like to check if two ndarrays are overlapping views of the same underlying ndarray.
To check that two slices are exactly the same, I can do something like:
numpy.may_share_memory() is the best heuristic that we have at the moment. It is conservatively heuristic; it may give you false positives, but it will not give you false negatives. I think there might be ways to improve the heuristic to be 100% correct. If they pan out, they will be folded into that function, so that's the best way forward.
It might be possible to compare where the indices live in memory using the ctypes property of the arrays. It might take some work, so you might want to step back and see if there is a different way of solving your problem.