a small problem

Thomas Wouters thomas at xs4all.net
Wed Jan 12 08:51:07 EST 2000


On Tue, Jan 11, 2000 at 11:23:29PM -0500, Tim Peters wrote:

> Whereas people like Guido <wink> would not have considered writing anything
> other than
> 
> >>> sum = 0
> >>> for n, s in q:
>         sum = sum + n

Aahh, yes. I dont know what I was thinking when I wrote it using map and
reduce instead of a much more obvious for loop. My only excuse is that it
was late yesterday night, and I'd just come back from an Amsterdam Perl
Mongers meeting. Amusing evening, but it probably confused me into using the
least obvious of all the ways to do it ;)

> Seriously, I don't think I've ever seen a good use for reduce in Python --
> although I've certainly used it <wink>.

People still care about speed. I know I sometimes do, even though I know
intellectually that it isn't going to matter much in the end product. I
still like to make it as speedy as possible, even if that entails using
map/reduce or odd looking constructions like 'def spam(text, None=None)'. I
suspect the use of map/reduce will drop when python is optimisable enough
to make the for loop _feel_ faster than map(). Static typing and what not.

On the other hand, oneliners will always feel or look faster to some people.
I'm one of them, I must admit. Another thing is the geekiness and
playfulness of oneliners. 'look, mom, only one line.' Maybe this is where
list comprehensions come in ;)

[ <snip> Guido saying lambda's suck (compared to the rest of python) ]

> I suppose finally posting that will rekindle a few old flamewars!  Brrrr.

Weeellll, I never bothered much with flamewars (though I did see a spot of
red when Tom Christiansen made his appearance last year) but I was always
sceptical when I heard someone say such things. Surely lambda's are good in
some cases ! But lately I've been looking at a lot of things differently and
considering wether the good it brings in some cases justifies the pain it
brings in other cases (this goes for much more than just lambda, python,
computers or corporeality, though.)

So I hope potential flamers are willing to take a step back and do what I
originally did. Start with thinking, "Guido Is Right", then consider, "Why
is Guido right ? What is he saying, exactly ?" and ending up in argument
with yourself. If you do end up thinking lambda's are guido's gift to sane
coding, at least you'll be prepared for the flamewar, having heard all
arguments.

It's important, though, once started, to finish this process. Dont get stuck
at 'Guido Is Right', even if it's a very comfortable situation and nobody is
going to notice in the end. The bureau of AFT might pull a Waco on Guido,
after all :P

> can't-believe-he'd-drink-coffee-with-a-straw-ly y'rs  - tim

it's-an-old-dutch-delicacy---irish-coffee-ly y'rs.
-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list