AI engineering glossary · Python advanced
What is generator expression?
Generator expression: A compact way to build a generator using comprehension-like syntax in parentheses. It computes items lazily instead of creating a full list in memory, which suits large data pipelines. It is the lazy counterpart of a list comprehension.
Generator expression: an example
sum(x * x for x in range(1_000_000)) adds the squares without storing a million numbers.
Related terms
More Python advanced terms
Where you learn it
Generator expression is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.