lazy evaluation

Postponing work until its result is actually needed, rather than doing it all in advance.

In more detail

Lazy code can skip work whose result is never used, and it can handle very large sequences with little memory because values are produced one at a time. Examples include Python generators, Java streams and loading related database records only when they are first accessed. The cost is that a lazy sequence can often be consumed only once.

Related terms

Taught in

References