An iterable is an object whose contents can be visited sequentially, such as with a Python for loop. Lists, sets, and dictionaries are examples. section 4.2.3
Iterating through n elements takes O(n) time. Collections usually store all their contents in memory, while generators produce one value at a time and avoid storing every result. section 4.2.3
A generator as a memory-friendly iterable
A generator can yield each square only when requested: def squares(items): for item in items: yield item ** 2. This keeps produced values from accumulating in memory. section 4.2.3
Built-in functions also accept iterables. For example, max can inspect a list, set, or dictionary, and its key function can specify what should be compared. section 4.3.2






