[Numpy-discussion] Determining if two arrays share data

Rob W.W. Hooft rob at hooft.net
Thu Jul 6 06:09:55 CDT 2006

Albert Strasheim wrote:
> I think we might be talking about two related but different concepts. One is
> sharing of data between arrays, the other is whether the data overlaps.

When is it useful to know whether data buffers overlap? As long as they 
are disjoint, it should be irrelevant at the higher level of the program.

> Let's assume we can get at the starting address of the array in memory via
> the array interface or whatever, and the length of the array in bytes.
> To determine whether two arrays overlap, find the smallest data address of
> the two arrays. If the data address of the other array is smaller than the
> sum of the smallest data address and its corresponding length, you have
> overlap.

Don't forget the strides.


Rob W.W. Hooft  ||  rob at hooft.net  ||  http://www.hooft.net/people/rob/

More information about the Numpy-discussion mailing list