Use itertoolz.sliding_window.