The itertools module is a toolbox of lazy tools. Building a few of your own is the best way to understand how they work, and why they use so little memory. This project writes chunked, windowed, interleave, flatten, a function that drops repeats, and a Peekable iterator that can look ahead, and then proves that they are lazy by counting how many items their sources produced.
More lessons in Complete Python Programming