[Python-ideas] a new lambda syntax

Michael Foord fuzzyman at gmail.com
Tue Oct 20 00:33:48 CEST 2009

2009/10/19 Oleg Broytman <phd at phd.pp.ru>

> On Mon, Oct 19, 2009 at 10:28:58PM +0800, starwing wrote:
> > Oleg Broytman ??????:
> >>    Single-line lambdas are good enough,
> >> and if you need more - just create a named function.
> >>
> > BUT, why we need a name? just to process something or make decide,
> > sometimes code itself is enough.
>    A multiline function is certainly not a simple piece of code; it
> requires documentation - docstring, comments - and the name is a part of
> the documentation.

Having used languages that allow multiline anonymous functions (C#,
Javascript) I have to say that they *can* improve the readability of code.
Being forced to define functions ahead of where they belong in the logical
flow of the program is not a feature of Python but a restriction.

To dogmatically assert that multiline anonymous functions are *necessarily*
less clear simply does the reputation of Python damage to those who use them
already in other languages and know that this isn't true.

I accept that it is a necessary restriction in Python (basically impossible
to find a clean syntax that fits in with indentation for block structure)
but to pretend that it is anything other than a restriction insults the
intelligence of your audience.


> > and, is there performance problems when you define a inner function in
> > another function? (that's, that function will define every time you call
> > the function or not?)
>    A lambda, like an inner function, is recreated every time, so it's
> certainly no better than a named function.
>   You should profile your program to prove there is really a performance
> degradation. And if there is - create a global function instead.
> Oleg.
> --
>     Oleg Broytman            http://phd.pp.ru/            phd at phd.pp.ru
>           Programmers don't die, they just GOSUB without RETURN.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20091019/b557962e/attachment.html>

More information about the Python-ideas mailing list