4 ms·
Well, my mistake, map and filter are not faster than a list comprehension (at least not in 2.7) My test case is: f = [x^2 for x in l if (x % 2) == 0] (and some
by raverbashing 14y ago
Well, my mistake, map and filter are not faster than a list comprehension (at least not in 2.7)
My test case is: f = [x^2 for x in l if (x % 2) == 0]
(and something similar with map and filter)
(where you read x^2 please consider x(double asterisk)2)
For 500k elements - xrange(500000) - this takes:
0.122527122498 (list comprehension)
0.145442008972 (map/filter)