[Tutor] Regular User defined functions Vs Generator functions
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Oct 31 19:41:35 EDT 2020
On 31/10/2020 17:54, Mats Wichmann wrote:
> the caller is going to immediately consume the entire result of the
> function, and there's potentially a large number of values, then there's
> not really any point in having it be a generator,
Yes but its hard to predict those ud cases.
On the other side if the client may not consume all the
values and break on finding the Nth item or one that matches
some criteria then a generator makes perfect sense for
large data sets.
There is no single, simple answer. You need to understand
the requirements and for 90% of the time it won't make much
practical difference!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list