title: numpy stride_tricks.as_strided vs list comprehension for rolling window
body: <p>When dealing with rolling windows, I wrote my functions in the way like list comprehension</p>
  
  <pre><code>[np.std(x[i:i+framesize]) for i in range(0, len(x)-framesize, hopsize)])]
  </code></pre>
  
  <p>Recently I discovered <code>numpy.lib.stride_tricks.as_strided</code> and found it is used widely for rolling windows (for example, <a href="http://www.rigtorp.se/2011/01/01/rolling-statistics-numpy.html" rel="nofollow">this post</a>), even though it is a "hidden" function.</p>
  
  <p>In <a href="https://github.com/numpy/numpy/issues/6565" rel="nofollow">this issue</a> concerning why stride_tricks.as_strided is undocumented, it's mentioned that </p>
  
  <blockquote>
    <p>Intentionally! It's dangerous! It was just low-level plumbing to help implement broadcast_arrays().</p>
  </blockquote>
  
  <p>Is there any advantage for <code>stride_tricks.as_strided</code> over the list comprehension or a for loop? I had a look at <a href="https://github.com/numpy/numpy/blob/master/numpy/lib/stride_tricks.py" rel="nofollow">the source code of <code>stride_tricks</code></a> but gained little.</p>