On 02Mar2021 15:06, Larry Martell <larry.mart...@gmail.com> wrote:
>I discovered something new (to me) yesterday. Was writing a unit test
>for generator function and I found that none of the function got
>executed at all until I iterated on the return value.

Aye. Generators are lazy - they don't run at all until you ask for a 
value.

By contrast, this is unlike Go's goroutines, which are busy - they 
commence operation as soon as invoked and run until the first yield 
(channel put, I forget how it is spelled now). This can cause excessive 
CPU utilisation, but it handle for _fast_ production of results. Which 
is a primary goal in Go's design.

Cheers,
Cameron Simpson <c...@cskk.id.au>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to