Skip to main content
Part 5 of 7 · Chapter 3 of 4

Producing Values One at a Time

A list built to hold a million numbers holds all million in memory at once, whether you need them yet or not. Write a generator instead, pull one value at a time, and watch it produce the next number only when asked.

Advanced11 min read

Read first: Naming a Piece of Work


Make a free account to read on

Every chapter is free — an account is how your progress, XP, and streak follow you from your laptop to your phone, and how you show up on the leaderboard. No payment, no trial.