In [1]:
import numpy as np

In [2]:
a = np.arange(10)
print(a)


[0 1 2 3 4 5 6 7 8 9]

In [3]:
a_0 = a[::2]
print(a_0)


[0 2 4 6 8]

In [4]:
a_1 = a[1::2]
print(a_1)


[1 3 5 7 9]

In [5]:
print(np.shares_memory(a_0, a_1))


False

In [6]:
print(np.may_share_memory(a_0, a_1))


True

In [7]:
a_2 = a[:5]
print(a_2)


[0 1 2 3 4]

In [8]:
a_3 = a[5:]
print(a_3)


[5 6 7 8 9]

In [9]:
print(np.shares_memory(a_2, a_3))


False

In [10]:
print(np.may_share_memory(a_2, a_3))


False

In [11]:
%%timeit
np.shares_memory(a_0, a_1)


839 ns ± 53.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

In [12]:
%%timeit
np.may_share_memory(a_0, a_1)


275 ns ± 5 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)