sliding window views
Published 2025-05-07 • Updated 2025-05-08
np.lib.stride_tricks.sliding_window_view(arr, win) lets you compute rolling stats without allocating O(n*win) memory. Pretty neat.
- Each window is a view that re‑uses underlying bytes; watch out for write‑after‑read mutations
- Good pattern: build view -> aggregate along last axis -> immediately release reference