Skip to content
Sharp

Iterators and Generators · interview question

What is the healthiest performance judgment around iterator protocol?

Multiple choiceHardchapter-8-curatedpremiumiterators-and-generatorsiterator-protocol
python
numbers = iter([1, 2, 3])
print(next(numbers))
print(next(numbers))
Choose one answer
Answer and explanation

Correct answer

C. Measure before optimizing, then change the part that actually dominates cost instead of guessing from style alone.

Why

Premature optimization is usually weaker than targeted optimization backed by measurement.

Test yourself on Iterators and Generators

A free test with instant, explained results. No account needed.

Start free test
All Iterators and Generators questions →