20 ms·
Generator expressions are horribly slow. I agree they are prettier, and I put them where they aid readability and don't hurt performance, but in general, gener
by pavpanchekha 14y ago
Generator expressions are horribly slow. I agree they are prettier, and I put them where they aid readability and don't hurt performance, but in general, generators involve creating (the equivalent of) a class with methods, and calling those methods. A generator is not only a function call, but it also restores state internal to the function, which is very expensive.