Lazy and Eager Transformations

An eager transform computes its results before returning them. A lazy transform can delay each computation until the result is requested.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace early termination
  2. Verify repeated consumption

Trace early termination

Suppose an operation squares 1, 2, and 3 but the caller needs only the first result. A lazy stream can compute just one square. A list-building mapping loop constructs all three results.

Verify repeated consumption

A lazy one-pass source may produce no data on a second pass or read a different external state when constructed again. Describe these expectations and when failures become observable. See generator suspension.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩