A special function that can pause its execution and resume later, yielding values one at a time instead of computing all results at once. It maintains its state between calls, enabling lazy evaluation and memory-efficient iteration.
The term 'generator' comes from mathematics, meaning something that produces or creates. First implemented in CLU in the 1970s, the concept was popularized by Python in 2001 with PEP 255, emphasizing the function's ability to 'generate' a sequence of values on demand rather than all at once.
Generator functions are like having a magic vending machine that only makes your snack when you press the button, and remembers exactly where it left off! Unlike regular functions that run to completion, generators can pause mid-execution with 'yield', making them perfect for processing huge datasets without running out of memory.
Complete word intelligence in one call. Free tier — 50 lookups/day.