0

What is difference b/w generator and list comprehensions and creating a list by a loop

Why we use generators

22nd Jul 2020, 3:58 AM
Saurabh Jangra
Saurabh Jangra - avatar
1 Answer
+ 4
Generator would use less memory, because it doesn't store the yielded values. If you needed to store the values generator may not be the best choice. List comprehension might be the fastest way to create a list.
22nd Jul 2020, 8:58 AM
Seb TheS
Seb TheS - avatar