読者です 読者をやめる 読者になる 読者になる

IPythonデータサイエンスクックブック

レシピ4.5

import numpy as np

 

def id(x):

  return x.__array_interface__['data'][0]

 

a=np.array([1,2,3,4,5,6,7,8,9,10])
print(id(a))

print(id(a[1:]))

 

out[]  

66570080 66570084

4*8bit=32bit


import numpy as np

a = np.random.rand(5000,5000)

%timeit a[0,:] .sum()
%timeit a[:,0] .sum()
The slowest run took 13.13 times longer than the fastest. This could mean that an intermediate result is being cached 100000 loops, best of 3: 3.17 µs per loop 10000 loops, best of 3: 53.8 µs per loop

 

レシピ4.6

x = np.zeros(10)

print(x.strides)

y = np.zeros*1
print(y.strides)

 

 
(8,)
(80, 8)

 

積読

 統計処理ポケットリファレンス

 
 



 

*1:10,10