0

What are practical usage examples of Python generators?

30th Nov 2017, 7:32 PM
pitmod
3 Antworten
30th Nov 2017, 8:37 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 1
@Ferhat Sevim: I was wondering about real life scenarios of using generators
30th Nov 2017, 9:27 PM
pitmod
+ 1
If you use a long list, the whole list is stored in the memory. This is not a huge problem, if your memory is big enough. However in some cases you can have problems, for example in a microcontroller environment, where your devices are not as powerful as your PC. Generators will need some processing time, but they eat up much less memory.
1st Dec 2017, 12:00 AM
Péter Kovács
Péter Kovács - avatar