Skip to content

    yield in Generator Functions

    Web design & developmentyieldGenerator Suspension
    Reading time: 2 min.Editorially reviewed on:
    ← All terms

    Definition

    yield outputs a value from a generator function and preserves its state for continuation.

    A language construct that pauses a generator function, yields a value, and preserves its local state for continuation.

    Simply explained

    The function outputs a result and pauses. On the next call, it continues exactly at this point.

    Why it matters in practice

    The term contributes to secure, maintainable, and high-performance web applications as well as resilient technical decisions.

    Example from business

    An import processes large files as a generator without holding all records in memory.

    Limits and pitfalls

    • yield is not the same in all languages and does not automatically imply parallelism or asynchronous execution.

    Origin & history

    Generators and yield were popularized by languages like CLU, Python, C#, and JavaScript; semantics depend on the language.

    Use in mid-sized companies

    • Possible application: An import processes large files as a generator without holding all records in memory.

    Frequently asked questions

    What does yield mean in generator functions?

    A language construct that pauses a generator function, yields a value, and preserves its local state for continuation. What should you watch out for? yield is not the same in all languages and does not automatically imply parallelism or asynchronous execution.

    Sources

    Source checked on 10.10.2026. Editorial application examples are hypothetical; no proof of real customer results.

    Editorially reviewed on:

    On this page

    Next step

    Put knowledge into practice