shouldn't list comprehension be faster than for loops?
sturlamolden
sturlamolden at yahoo.no
Sat Dec 19 09:18:57 EST 2009
On 19 Des, 02:28, Ryan Kelly <r... at rfk.id.au> wrote:
> Not so. If you use the "dis" module to peek at the bytecode generated
> for a list comprehension, you'll see it's very similar to that generated
> for an explicit for-loop. The byte-code for a call to map is very
> different.
First, you failed to realize that the bytecode is different because
map is doing the work in C.
Second, you did not provide bytecode for the for-loop.
More information about the Python-list
mailing list