2 ms·
Fundamentally? No, it's all just machine language in the end. Practically? Yes, generators are often more memory-efficient, and thereby often more compute-effi
by xapata 3y ago
Fundamentally? No, it's all just machine language in the end.
Practically? Yes, generators are often more memory-efficient, and thereby often more compute-efficient.
- Jeff_Brown 3y agoIs it only about efficiency, and not expressivity? If so, can the compiler figure out where to transform my equivalent structures into iterators and generators?
- xapata 3y agoThe expressivity gain depends on what you're left with without the feature. It was hard for me to imagine where the previous comment draws the line around iterators and generators. An optimizing compiler would need to know what actions are pure in order to rewrite code to be lazy. Python allows so much dynamism, I can only see that happening with a very sophisticated tracing JIT.