ELI5: Explain Like I'm 5

Generator (computer programming)

Generators are like special functions in computer programming that produce pieces of a result one at a time. Instead of running all the code at once, generators pause after each piece, and wait until they are asked to produce the next piece. It's like they are taking turns, instead of doing all the work at once. This can be useful when you don't need all the pieces of the result right away, and you want to save time and memory.
Related topics others have asked about: