The module provides fast, memory efficient tools that create iterators . These tools, inspired by constructs from APL, Haskell, SML, can be used individually or in various combinations. For example, SML has a
tabulate (f) that generates a sequence
f (0), f (1), ... , which in Python can be rendered as a
map (f, count ()) .
The tools provided by the module work well with the functions of the
operator module. For example, the multiplication operator can be applied to two vectors to efficiently compute the dot product:
sum (map (operator.mul, vector1, vector2)) .
repeat (). Provides a stream of unlimited length, so use it inside functions or loops that stop the stream.
chain (), < code> chain.from_iterable () ,
groupby ( ),
More primitives offering iterators to solve a set tasks can be taken from the package more-itertools . Primitives are also effective in minimizing memory consumption and speed.