Back to search

What is a generator?

A generator yields values lazily so you can stream work instead of building the whole collection at once.

Python Easy Theory

What is a generator?

A generator yields values lazily so you can stream work instead of building the whole collection at once.

  • Uses yield
  • Keeps state between iterations
  • Good for large data

What is a generator?