Multi-isinstance idiom (Re: Deprecate tabs for indenting (was Re: Indenting with tabs vs spaces))
Fernando Pérez
fperez528 at yahoo.com
Thu Dec 6 10:14:27 EST 2001
Tim Peters wrote:
> [Mike C. Fletcher]
>> ...
>> AFAIK, list comprehensions are basically just syntactic sugar
>> around
>> regular loops, so they aren't likely any faster than a for loop.
>> If that's changed, it would be good to know.
>
> They are just sugar, but are nevertheless faster than the for loop
> most sane <wink> people are *likely* to write (the generated code
> uses a bound method object for the hidden list.append, doing the
> method lookup just once before the loop begins).
Can you comment on list comprehensions vs. map? I tend to shy away
from the convenience of comprehensions because I'm afraid of their
cost and --at the expense of clarity-- pretty much anything can be
written with map().
Curious,
F.
More information about the Python-list
mailing list