I sing the praises of lambda, my friend and savior!

Frohnhofer, James james.frohnhofer at csfb.com
Wed Oct 13 15:34:59 EDT 2004


While I can't confirm your figures, I couldn't agree with your conclusions
more.  Simply put, lambda is intention revealing in a way that a function def
cannot be.  Further, the greatest cost savings is in program maintenance,
where lambda guarantees that a change I make will be local.

> -----Original Message-----
> From: python-list-bounces+james.frohnhofer=csfb.com at python.org
> [mailto:python-list-bounces+james.frohnhofer=csfb.com at python.org]On
> Behalf Of Clark C. Evans
> Sent: Wednesday, October 13, 2004 3:09 PM
> To: Jeff Shannon
> Cc: python-list at python.org
> Subject: Re: I sing the praises of lambda, my friend and savior!
> 
> 
> On Wed, Oct 13, 2004 at 10:47:56AM -0700, Jeff Shannon wrote:
> | Except that the Python philosophy is that overall, the 
> greatest clarity 
> | is achieved by having a single obvious way to do things.
> 
> When doing coding that uses alot of callbacks, use of lambda for
> tiny, nameless, single-use expressions is the "single obvious way to
> do something".
> 
> Assume for a moment the following programming costs:
> 
>   2m  Minting a name, that is, finding a name that is not 'foo'
>       which semantically adds to the readability and maintainability
>       of the code.
>         
>   30s Verifying that a function name is not used more than once to 
>       verify that changing its definition, or if it is reused, 
>       making sure all the places where a change would affect is OK.
> 
> In one of my files, I've got 20 or so lambdas, typically only a few
> characters to plug-in a computation.  You're asking me to pay a 40
> minute price just to mint names in this file?  Then, I've had, over
> the past year about 20 edits on that file, some of which change a
> few of these lambdas, say 2 changes per edit on average.  That's
> another 20 minutes.  So, over the last year, in this one file alone,
> not having lambdas would have cost me an additional hour of time!
> I've got 2 largish projects, each averaging about 20 files, so
> that's about 40 hours of time chewed up with small efficiency hits.
> Or, about $4,000 of billable time.   I'd rather keep the money or
> take a vacation, thank you very much.
> 
> I use Python beacuse it is a horribly efficient language for me to
> write software with; it is efficient beacuse I have the flexibiltiy
> to use several different constructs depending on which is more
> clearly expresses the intent of the developer. While lambda is a
> small part of this effiency, it is a factor.  It clearly expresses a
> simple, nameless single chunk of code that is never reused.
> 
> Propose another construct that has these features, and I'll gladly
> use it instead of lambda.
> 
> Best,
> 
> Clark
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

==============================================================================
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==============================================================================




More information about the Python-list mailing list