News for hackers. Stuff that matters.
Re:Python is not a great programming language by novok on Saturday October 12, 2019 @05:02PM (#21236271)
You can decompose any list comprehension into it's equivalent for loop fairly easily. I don't see what is so magic about them other than the language having a special compiler level optimization for them?

g = [i for i in list if x == 3] -> g = []; for i in list: if x == 3: g.append(i);

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