rfc:comprehensions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
rfc:comprehensions [2019/03/11 11:53] – fix typos in code nikic | rfc:comprehensions [2019/04/05 01:10] (current) – Revise explanation of generator choice. crell | ||
---|---|---|---|
Line 171: | Line 171: | ||
- In most cases it doesn' | - In most cases it doesn' | ||
- Cases where it does matter are where the list is especially large, or especially expensive to generate and only selected values will be used. In those cases a generator is superior as it minimizes the memory and CPU usage (respectively) needed to represent values. | - Cases where it does matter are where the list is especially large, or especially expensive to generate and only selected values will be used. In those cases a generator is superior as it minimizes the memory and CPU usage (respectively) needed to represent values. | ||
- | - If an actual array is desired, converting a generator to an array is a trivial call to '' | + | - If an actual array is desired, converting a generator to an array is a trivial call to '' |
+ | - That is, a greedy-list value can be composed out of a lazy-list value and a expansion operation. | ||
- A compact syntax to produce a generator allows for some nifty functional programming techniques that until now have been verbose to implement for non-array iterators. | - A compact syntax to produce a generator allows for some nifty functional programming techniques that until now have been verbose to implement for non-array iterators. | ||
rfc/comprehensions.1552305230.txt.gz · Last modified: 2019/03/11 11:53 by nikic