Are list comprehensions syntactic sugar for `list(generator expression)` in Python 3?
Both work differently. The list comprehension version takes advantage of the special bytecode LIST_APPEND which calls PyList_Append directly for us. Hence it avoids an attribute lookup to list.append and a function call at the Python level. >>> def func_lc(): [x**2 for x in y] … >>> dis.dis(func_lc) 2 0 LOAD_CONST 1 (<code object <listcomp> at … Read more