Concept: Generator vs List
Concept Check Medium
Question
Why are generators more memory-efficient than lists?
Hint
Think about when the values are created.
Explanation
Generators produce values lazily — one at a time, on demand — instead of storing all values in memory at once. For large or infinite sequences, this means you only hold one value in memory at a time, making generators far more memory-efficient than lists.
Related Resources
Related Lessons
- Generators
Generator efficiency.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.