❔ Interview Question
Explain the concept of generators in Python and how they differ from regular iterators in terms of memory efficiency.
Generators are functions that use
tags: #interview #python #generators #memory
@DataScienceQ⭐️
Explain the concept of generators in Python and how they differ from regular iterators in terms of memory efficiency.
Generators are functions that use
yield to produce a sequence of values lazily (e.g., def gen(): yield 1; yield 2), creating an iterator that generates items on-the-fly without storing the entire sequence in memory, unlike regular iterators or lists which can consume more RAM for large datasets—ideal for processing big data streams efficiently.tags: #interview #python #generators #memory
@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM