List comprehension vs generator expression’s weird timeit results?
I was answering this question, I preferred generator expression here and used this, which I thought would be faster as generator doesn’t need to create the whole list first:
I was answering this question, I preferred generator expression here and used this, which I thought would be faster as generator doesn’t need to create the whole list first:
The following behaviour seems rather counterintuitive to me (Python 3.4):
The following test fails:
I can use if
and for
in list comprehensions/generator expressions as