What's the true purpose of generators? Why not use lists and range function instead? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the true purpose of generators? Why not use lists and range function instead?

15th Feb 2016, 10:28 AM
Diego Chinellato
Diego Chinellato - avatar
2 Answers
0
"Using generators results in improved performance, which is the result of the lazy (on demand) generation of values, which translates to lower memory usage. Furthermore, we do not need to wait until all the elements have been generated before we start to use them." This is taken straight from the third part of this module :)
17th Nov 2016, 4:37 PM
Luke Harrison
Luke Harrison - avatar
- 3
No tener una lista preconcebida, ir generando sobre la marcha.
15th Apr 2016, 11:09 PM
camelo
camelo - avatar