Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
One of the fundamental changes in Python 3.0 is that it has
a stronger emphasis on iterators than 2.X. In addition to the iterators
associated with built-in types such as files and dictionaries, the
dictionary methods keys, values, and items return iterable objects in Python 3.0,
as do the built-in functions range,
map, zip, and filter. As shown in the prior section, the
last three of these functions both return iterators and process them.
All of these tools produce results on demand in Python 3.0, instead of
constructing result lists as they do in 2.6.
Although this saves memory space, it can impact your coding
styles in some contexts. In various places in this book so far, for
example, we’ve had to wrap up various function and method call results
in a list(...) call in order to
force them to produce all their results at once: