3 ms·
> Generators vs list comprehensions I'm a bit confused. Which one is faster?
by ak217 14y ago
> Generators vs list comprehensions
I'm a bit confused. Which one is faster?
- robert-zaremba 14y agolist comprehensions of course!
- signed0 14y agoThe exclamation led me to believe you were being facetious, but https://bitbucket.org/pypy/pypy/wiki/JitFriendliness https://bitbucket.org/pypy/pypy/wiki/JitFriendliness agrees with you: "As of now (Feb 2011) generators are usually slower than corresponding code not using generators. Same goes for generator expressions. For most cases using list comprehension is faster."