map/filter/reduce/lambda opinions and background unscientific mini-survey
steve at REMOVEMEcyber.com.au
Mon Jul 4 06:04:16 CEST 2005
Mike Meyer wrote:
> Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
>>I don't object to adding sum and product to the language. I don't object
>>to adding zip. I don't object to list comps. Functional, er, functions
>>are a good thing. We should have more of them, not less.
> Yes, but where should they go? Adding functions in the standard
> library is one thing. Adding builtins is another. Builtins make every
> python process heavier. This may not matter on your desktop, but
> Python gets used in embedded applications as well, and it does
> there. Builtins also clutter the namespace. Nothing really wrong with
> that, but it's unappealing.
> I'd say that removing functions is a bad thing. On the other hand, I'd
> say moving them from builtins to the standard library when Python has
> functionality that covers most of the use cases for them is a good
> The latter has occured for map, filter, and reduce. Lambda I'm not so
> sure of, but it gets swept up with the same broom. Moving the first
> three into a library module seems like a good idea. I'm not sure about
> removing lambda. Removing map, filter and reduce remove most of my
> use cases for it. But not all of them.
Practicality beats purity: I am perfectly happy to have
list comps in the language and fast, efficient
functional programming tools in a module. I'm even
happy to see sum and product and zip as builtins, even
though logically they belong with map and reduce in the
(hypothetical) functional module.
I know Python isn't, and never will be, a purely
functional language. But being able to use some
functional techniques is good, and shouldn't be lost.
More information about the Python-list