[Tutor] list comprehension, efficiency?

Lie Ryan lie.1296 at gmail.com
Tue Sep 28 08:06:56 CEST 2010

On 09/28/10 13:57, Bill Allen wrote:
> I can now see that quite a bit of the code I write dealing with lists
> can be done with list
> comprehensions.   My question is this, is the list comprehension styled
> code generally
> more efficient at runtime?  If so, why?

Yes, because the looping in list comprehension is done in C instead of a
python construct. However, they are the type of efficiency that you
shouldn't bother yourself with unless you're microoptimizing.

More information about the Tutor mailing list