You can't do that in compiler unless you can someh...
# language-proposals
d
You can't do that in compiler unless you can somehow make sure that reordering operations is fine. There are some good alternatives: 1. Use sequences (which provide lazy evaluation semantics). That's still some additional allocations (for Sequence objects), but not as much as for intermediate lists. 2. Use coroutines. That's one additional allocation (for corresponding state machine). 3. (new language feature) Introduce some form of collection comprehensions, which would allow some more freedom for the compiler in terms of generated code.