A generator is a lazy iterator. You can loop over lazy iterators as you would a list. Also, generators do not store their contents in memory.
Why use a generator? First and foremost, they're fun! But, beyond that, they use less memory and are faster -- sometimes orders of magnitude faster!
Code on GitHub:
https://github.com/poly451/Tutorials/tree/master/Generators
Visit me on Twitter:
https://twitter.com/Strange451
Download
0 formats
No download links available.
Python Generators: What They Are And What They're Good For | NatokHD