54
When should I use list comprehension vs map() and filter() in Python?
For example, these seem to do the same thing:
# List comprehension
squares = [x**2 for x in range(10)]
# map
squares = list(map(lambda x: x**2, range(10)))Which is more Pythonic? Which is faster? When should I use each?