title: Fastest way to create an array in Python
body: <p>I want to create a 3D array in Python, filled with -1.</p>
  
  <p>I tested these methods:</p>
  
  <pre><code>import numpy as np
  l = 200
  b = 100
  h = 30
  
  %timeit grid = [[[-1 for x in range(l)] for y in range(b)] for z in range(h)]
  1 loops, best of 3: 458 ms per loop
  
  %timeit grid = -1 * np.ones((l, b, h), dtype=np.int)
  10 loops, best of 3: 35.5 ms per loop
  
  %timeit grid = np.zeros((l, b, h), dtype=np.int) - 1
  10 loops, best of 3: 31.7 ms per loop
  
  %timeit grid = -1.0 * np.ones((l, b, h), dtype=np.float32)
  10 loops, best of 3: 42.1 ms per loop
  
  %%timeit
  grid = np.empty((l,b,h))
  grid.fill(-1.0)
  100 loops, best of 3: 13.7 ms per loop
  </code></pre>
  
  <p>So obviously, the last one is the fastest. Does anybody has an even faster method or at least less memory intensive? Because it runs on a RaspberryPi.</p>