Iterators

Let's discuss iterators and their types.

Python provides a great module for creating our own iterators. The module we are referring to is itertools. The tools provided by itertools are fast and memory efficient. We will use these building blocks to create our own specialized iterators that can be used for efficient looping. In this chapter, we will be looking at examples of each building block so that by the end we will understand how to use them for our own code bases.

Let’s get started by looking at some infinite iterators!

The infinite iterators

The itertools package comes with three iterators that can ...

Access this course and 1400+ top-rated courses and projects.