Re:Python is not a great programming language
by mplanchard on Saturday October 12, 2019 @05:48PM
(#21236598)
I see people frequently say that list comprehensions are special-cased and highly optimized by the compiler, but I did a few experiments recently with `timeit` and found that using `map()` is on the order of 1.5x faster in all the cases I tested. I think that either winds up being faster than a manual for loop, though
g = [i for i in list if x == 3] -> g = []; for i in list: if x == 3: g.append(i);