4 ms·
> the removal of map and filter from the core language This never happened-- perhaps you're thinking of reduce? And reduce is still in it, it just got moved to
by kevinmgranger 9y ago
> the removal of map and filter from the core language
This never happened-- perhaps you're thinking of reduce? And reduce is still in it, it just got moved to `functools`.
- empthought 9y agoHah, I didn't even know that it never happened. Goes to show the relative utility of map/filter vs comprehensions...
- amyjess 9y agoIt was proposed to do that with all three, and they walked it back to just reduce because there was a huge outcry.
- brudgers 9y agoThanks, I stand corrected. My high level memory is that the map->filter->reduce idiom was broken because <arbitrary>. Adding to my confusion was my conflating that <arbitary> with my memory of map breaking code by returning a map object rather than a list.
- kevinmgranger 9y agoYou'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...