generator expression

A comprehension written in parentheses, which produces its items one at a time on demand instead of building a whole list.

In more detail

sum(x * x for x in range(1_000_000)) never holds a million numbers in memory. Like any generator it can be used only once.

Related terms

Taught in

References

Certification courses