Increased Use of Iterators in 3.0
Friday January 9, 2009
In addition to changes in print syntax and increased use of views, Python 3.0 also sees an increased underlying use of iterators. Many built-in functions that previously returned lists now return iterators.
An iterator is a simple generator that returns the next in a series of values. Where lists keep a static rota of values, iterators keep track of what the last value returned was and then return the next value in the series. This helps to keep resources used to a minimum, among other benefits.
For a list of the functions affected, see "From Lists and Tuples to Iterators", the latest in the series "Transitioning from 2.x to 3.0".
An iterator is a simple generator that returns the next in a series of values. Where lists keep a static rota of values, iterators keep track of what the last value returned was and then return the next value in the series. This helps to keep resources used to a minimum, among other benefits.
For a list of the functions affected, see "From Lists and Tuples to Iterators", the latest in the series "Transitioning from 2.x to 3.0".
