Tutorials

Reinventing the `itertools` wheel for fun and profit

Thursday, May 15th, 2025 1:30 p.m.–5 p.m. in Room 310/311

Presented by

Rodrigo Girão Serrão

Experience Level:

Some experience

Description

In this hands-on tutorial we will reinvent the wheel and implement the module itertools in plain Python.

We'll do that because that will teach us a lot about Python:

  • how generators and lazy iteration work;
  • the difference between iterables and iterators;
  • what the built-ins iter and next do;
  • how Python handles iteration and for loops under the hood;
  • what the iterator protocol is;
  • how the dunder methods __iter__ and __next__ play a part in all this; and
  • we'll also learn about the functions inside itertools, a module with plenty of useful tools for your day-to-day iterations.

And most importantly, we'll do it because it's genuinely fun!

Search