[Python-Dev] functools.compose to chain functions together

Nick Coghlan ncoghlan at gmail.com
Mon Aug 17 12:53:20 CEST 2009


Antoine Pitrou wrote:
>> PEP 309 was written, discussed, approved, and implemented - that's how
>> partial ended up in the stdlib.
> 
> Ok, I'm surprised that a single addition to a module needed a PEP in
> order to be approved.

It makes a little more sense once you realise that there was no
functools module before the implementation of PEP 309. The other
functions it contains in Python 2.5 (update_wrapper() and wraps()) were
added later in the development cycle and reduce() didn't get added to it
until 2.6/3.0.

If a concrete proposal is made that emphasises the improved
introspection capabilities and raw speed increase that a function
composition approach can offer over the use of lambda then I'd
personally be willing to support this idea, since it was at least in
part those two ideas that sold the idea of partial(). (partial() did
have a big advantage over compose() in that the former's readability
gains were far more obvious to most readers).

Cheers,
Nick.

P.S. PEP 309 is wrong when it says a C version probably isn't worthwhile
- between the time the PEP was first implemented and the time 2.5 was
actually released, enough investigation was done to show that the speed
gain from Hye-Shik Chang's C version was well worth the additional code
complexity.


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list