numpy stride_tricks.as_strided vs list comprehension for rolling window
问题 When dealing with rolling windows, I wrote my functions in the way like list comprehension [np.std(x[i:i+framesize]) for i in range(0, len(x)-framesize, hopsize)])] Recently I discovered numpy.lib.stride_tricks.as_strided and found it is used widely for rolling windows (for example, this post), even though it is a "hidden" function. In this issue concerning why stride_tricks.as_strided is undocumented, it's mentioned that Intentionally! It's dangerous! It was just low-level plumbing to help