On Fri, 25 May 2012 18:28:28 +1000
Nick Coghlan
On Fri, May 25, 2012 at 5:53 PM, Mark Summerfield
wrote:
In an effort to keep the core language as small as possible (to keep it "brain sized":-) would it be reasonable to deprecate filter() and map() and to move them to the standard library as happened with reduce()? After all, don't people mostly use list comprehensions and generator expressions for these nowadays?
Wasn't this changed discussed for that very reason as part of the move to 3.x? Which makes me wonder why reduce moved but not map and filter, when map and filter have obvious rewrites as list comprehensions, but reduce doesn't? Seems backwards to me.
The basic problem is that the answer to your question is "no" - for preexisting functions, a lot of people still use filter() and map(), with the comprehension forms reigning supreme only when someone would have had to otherwise use a lambda expression.
Personally, I tend to favor list comprehensions most of the time (and
I was a pretty heavy user of map and filter in the day), because it's
just one less idiom to deal with. The exception is when they'd nest -
I use [map(f, l) for l in list-of-lists] rather than nesting the
comprehensions, because I then don't have to worry about untangling
the nest.
But I do agree that since they survived into 3.x, they need to stay
put until 4.x.