5 ms·
You're right in that map returned a list in python 2, but in python 3, it returns an iterator. Anyone who relied on indexing or non-lazy behavior would have the
by kevinmgranger 9y ago
You're right in that map returned a list in python 2, but in python 3, it returns an iterator. Anyone who relied on indexing or non-lazy behavior would have their code break.
GVR doesn't like functional-style programming, so he much prefers the iterative but compact comprehension alternatives.
It may just be the circles I hang out in, but most folks aren't map/filter versus comprehension purists. I'll do comprehensions usually, but map/filter when it helps make the line shorter or more readable.
- brudgers 9y agoI don't have anything against list comprehensions. Sometimes they are a very useful abstraction. Other times map->filter->reduce better expresses the business logic of the program (e.g. when the analog is signal processing [1] or Unix pipes). My issue with 'Pythonic' is that it is used to express the idea that someone's thoughts are or are not properly structured. [1]: https://mitpress.mit.edu/sicp/full-text/sicp/book/node35.html https://mitpress.mit.edu/sicp/full-text/sicp/book/node35.htm...