In [1]:
import numpy as np
In [2]:
a = np.arange(10)
print(a)
In [3]:
a_0 = a[::2]
print(a_0)
In [4]:
a_1 = a[1::2]
print(a_1)
In [5]:
print(np.shares_memory(a_0, a_1))
In [6]:
print(np.may_share_memory(a_0, a_1))
In [7]:
a_2 = a[:5]
print(a_2)
In [8]:
a_3 = a[5:]
print(a_3)
In [9]:
print(np.shares_memory(a_2, a_3))
In [10]:
print(np.may_share_memory(a_2, a_3))
In [11]:
%%timeit
np.shares_memory(a_0, a_1)
In [12]:
%%timeit
np.may_share_memory(a_0, a_1)