Generator

Noun · Development

Definitions

  1. A special type of function that returns an iterator which yields values one at a time using lazy evaluation, pausing execution between each yield and resuming where it left off when the next value is requested.

    In plain English: A function that produces values on demand instead of computing them all at once, saving memory by only doing work when you actually need the next result.

    Example: "We replaced the list comprehension with a generator and cut memory usage by 90% on the million-row export."

Related Terms