how do I check that two slices of numpy arrays are the same (or overlapping)?
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.
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.