--

Benchmarking shows the loop comprehension is about 10% faster for large lists: try it yourself.

It isn't always the case that loop comprehensions are faster, but in this case when you know the size of the input and there is no if clause in the comprehension, Python is able to preallocate the list in the comprehension, but not in the for statement, where the appends result in some reallocation and other overhead.

--

--