Are list comprehensions syntactic sugar for `list(generator expression)` in Python 3?
Are list comprehensions syntactic sugar for `list(generator expression)` in Python 3? In Python 3, is a list comprehension simply syntactic sugar for a generator expression fed into the list function? list e.g. is the following code: squares = [x**2 for x in range(1000)] actually converted in the background into the following? squares = list(x**2 for x in range(1000)) I know the output is identical, and Python 3 fixes the surprising side-effects to surrounding namespaces that list comprehensions had, but in terms of what the CPython interpreter does under the hood, is the former converted to the latter, or are there any difference in how the code gets executed? I found this claim of equivalence in the comments section to this question, and a quick google search showed the same claim being made here. There was also some mention of this in the What's New in Python 3.0 docs, but the wording is somewhat vague: Also note that list comprehensions have different semantics: they ar