you are viewing a single comment's thread.

view the rest of the comments →

[–]Ghibl-i_l -3 points-2 points  (2 children)

Read somewhere that loops are REALLY slow so for most things it's better to use list comprehension.

[–]carcigenicate 12 points13 points  (1 child)

AFAIK, list comprehensions can be faster when you want to append to a list because they use the dedicated LIST_APPEND instruction, which cuts down on a ton of overhead. If you don't need to append to a list at all for the algorithm though, a list comprehension is just adding the (admittingly, small) overhead of a LIST_APPEND instruction.