2 ms·
This is a nice little article, but I wonder about some of the design decisions. In particular: > The simplifications employed (for example, ignoring generators
by ggchappell 12y ago
This is a nice little article, but I wonder about some of the design decisions. In particular:
> The simplifications employed (for example, ignoring generators and the power of itertools when talking about iteration) reflect its intended audience.
Are generators really that hard? (Not a rhetorical question!)
The article mentions problems resulting from the creation of a temporary list based on a large initial list. So, why not just replace a list comprehension "[ ... ]" with a generator expression "( ... )"? Result: minimal storage requirements, and no computation of values later than those that are actually used.
And then there is itertools. This package might seem a bit unintuitive to those who have only programmed in "C". But I think the solution to that is to give examples of how itertools can be used to create simple, readable, efficient code.