Python Generators and itertools for Memory-Efficient Code
A list holds every item in memory. A generator produces items one at a time, on demand. For large files, streams or infinite sequences, that's the difference between working and running out of memory. yield def read_lines(path): with open(path) as f: for line...