[Numpy-discussion] test if two arrays share the same data

Puneeth punchagan@gmail....
Sun Sep 5 14:23:56 CDT 2010


2010/9/6 Ernest Adrogué <eadrogue@gmx.net>:
> Hi,
>
> How can it be done?
>
> id() doesn't do it:
>
> In [238]: a= np.arange(5)
>
> In [239]: id(a) == id(a[:])
> Out[239]: False
>
> Any ideas?

Checking for a[:].base and a[:].size works. I'm not sure if that is a
good way to do it.
(a[:].base is a and a[:].size == a)

-- Puneeth


More information about the NumPy-Discussion mailing list