PyCon 2019 | Lazy Looping in Python: Making and Using Generators and Iterators

Speaker: Trey Hunner


When processing large amounts of data in Python, we often reach for lists. Unfortunately, processing data using large lists make for ugly code that can be memory inefficient and slow. Python’s solution to this problem is lazy looping using generators and iterators.

During this tutorial we’ll learn a number of lazy looping techniques which will help you write more efficient and more readable Python code. We’ll get practice creating generators, playing with iterators, and using generators and iterators to drastically restructure our code in a more descriptive data-centric way.

You’ll walk out of this tutorial with hands-on experience with Python’s various lazy looping constructs and a greater appreciation for how looping works under the hood in Python.


Slides can be found at: and

Previous Python: A History in Tandem
Next PyCon 2019 | Dealing with Datetimes