Hacker News new | ask | show | jobs
by misterdoubt 2439 days ago
A list comprehension is still a for loop. Using `for x in list` instead of `for i in len(list)` is a nice bit of sugar, but still a for loop.

That said, high-performance Python does generally discourage the use of loops in favor of vectorised operations.

1 comments

I agree Python list comprehensions have loop semantics. But in fairness, a list comprehension in Python is an expression not a statement. Maybe it's best to think of Python's list comprehensions as loops with an implicit return.