Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Beazley on Generators

99 views
Skip to first unread message

Terry Reedy

unread,
Apr 1, 2009, 1:03:50 AM4/1/09
to pytho...@python.org
At PyCon2008, David Beazley presented an excellent talk on generators.
Generator Tricks for Systems Programmers
http://www.dabeaz.com/generators/index.html

At PyCon2009, he followed up with another talk on more advanced
generator usage, which Guido commended on the python-ideas list:
A Curious Course on Coroutines and Concurrency
http://dabeaz.com/coroutines/

I have just started (this one will take more than one sitting ;-) but it
looks just as good.

tjr

Michele Simionato

unread,
Apr 1, 2009, 1:21:37 AM4/1/09
to
On Apr 1, 7:03 am, Terry Reedy <tjre...@udel.edu> wrote:
> At PyCon2008, David Beazley presented an excellent talk on generators.
> Generator Tricks for Systems Programmershttp://www.dabeaz.com/generators/index.html

>
> At PyCon2009, he followed up with another talk on more advanced
> generator usage, which Guido commended on the python-ideas list:
> A Curious Course on Coroutines and Concurrencyhttp://dabeaz.com/coroutines/

>
> I have just started (this one will take more than one sitting ;-) but it
> looks just as good.
>
> tjr

I concur. I have just read the first pages, but it says
all good things I had to discover the hard way in years
past. Excellent reading for everybody wanting to understand
cooperative concurrency!

M. Simionato

Lawrence D'Oliveiro

unread,
Apr 1, 2009, 1:57:49 AM4/1/09
to
In message
<d2733ede-4d66-40a2...@q16g2000yqg.googlegroups.com>, Michele
Simionato wrote:

> Excellent reading for everybody wanting to understand cooperative
> concurrency!

Hey, some of us were doing "cooperative concurrency" programming old MacOS
for years. It was generally considered a poor alternative to "true
multitasking".

Michele Simionato

unread,
Apr 1, 2009, 4:22:30 AM4/1/09
to
On Apr 1, 7:57 am, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message
> <d2733ede-4d66-40a2-9a63-60d5363db...@q16g2000yqg.googlegroups.com>, Michele

It is a poor alternative compared to OS level processes and even
compared to preemptive threads in some cases. However, there are
situations
when you need thousands of lightweight threads of execution, and
in that case coroutines could be the only viable solution.
Just read David Beazley's presentation.

Kay Schluehr

unread,
Apr 1, 2009, 10:33:37 AM4/1/09
to
On 1 Apr., 07:03, Terry Reedy <tjre...@udel.edu> wrote:
> At PyCon2008, David Beazley presented an excellent talk on generators.
> Generator Tricks for Systems Programmershttp://www.dabeaz.com/generators/index.html

>
> At PyCon2009, he followed up with another talk on more advanced
> generator usage, which Guido commended on the python-ideas list:
> A Curious Course on Coroutines and Concurrencyhttp://dabeaz.com/coroutines/

>
> I have just started (this one will take more than one sitting ;-) but it
> looks just as good.
>
> tjr

There is just one thing I find disappointing. Since the talk is almost
a compendium of advanced uses of generators I'm missing a reference to
Peter Thatchers implementation of monads:

http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax.html

Peters implementation can be simplified but it already contains all
relevant ideas.

andrew cooke

unread,
Apr 1, 2009, 11:15:51 AM4/1/09
to Kay Schluehr, pytho...@python.org
Kay Schluehr wrote:
> There is just one thing I find disappointing. Since the talk is almost
> a compendium of advanced uses of generators I'm missing a reference to
> Peter Thatchers implementation of monads:
>
> http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax.html
>
> Peters implementation can be simplified but it already contains all
> relevant ideas.

oh that's neat. thanks for that. andrew

Peter Pearson

unread,
Apr 1, 2009, 12:48:10 PM4/1/09
to
On Wed, 01 Apr 2009 01:03:50 -0400, Terry Reedy <tjr...@udel.edu> wrote:
> At PyCon2008, David Beazley presented an excellent talk on generators.
> Generator Tricks for Systems Programmers
> http://www.dabeaz.com/generators/index.html
>
> At PyCon2009, he followed up with another talk on more advanced
> generator usage, which Guido commended on the python-ideas list:
> A Curious Course on Coroutines and Concurrency
> http://dabeaz.com/coroutines/

Great presentations. Thanks.

--
To email me, substitute nowhere->spamcop, invalid->net.

Craig Allen

unread,
Apr 1, 2009, 6:07:42 PM4/1/09
to
this is great, thanks... we have used generators to create something
akin to a cooperative tasking environment... not to implement
multitasking, but to be able to control low level data processing
scripts. These scripts, written as generators, yield control to a
control loop which then can pause, resume, abort, or change the state
of shared context objects which the script uses as it's input and
output space. E.g. the control loop can see there is intermediate
output which an operator (managing a data reduction pipeline) might
want to see.

I can see from the first few slide I need to understand this. It
already seems clear that there are ways to improve our approach to
what we have done, though the overall approach is solid and works
well.

anyway thanks.

Carl Banks

unread,
Apr 1, 2009, 6:23:03 PM4/1/09
to
On Mar 31, 10:03 pm, Terry Reedy <tjre...@udel.edu> wrote:
> At PyCon2008, David Beazley presented an excellent talk on generators.
> Generator Tricks for Systems Programmershttp://www.dabeaz.com/generators/index.html

>
> At PyCon2009, he followed up with another talk on more advanced
> generator usage, which Guido commended on the python-ideas list:
> A Curious Course on Coroutines and Concurrencyhttp://dabeaz.com/coroutines/

>
> I have just started (this one will take more than one sitting ;-) but it
> looks just as good.

Yet another great thing about Python. The ability to run coroutines
in Matlab would make my working life a lot easier right now.


Carl Banks

Lawrence D'Oliveiro

unread,
Apr 1, 2009, 6:37:46 PM4/1/09
to
In message <13298fc5-5024-4343-

bf5a-7e2...@o11g2000yql.googlegroups.com>, Michele Simionato wrote:

> However, there are situations when you need thousands of lightweight

> threads of execution ;;;

The Linux kernel has been tested running hundreds of thousands of threads.

Steven D'Aprano

unread,
Apr 1, 2009, 8:14:37 PM4/1/09
to

Did it pass or fail that test?

--
Steven

Paul Rubin

unread,
Apr 1, 2009, 10:02:48 PM4/1/09
to
Lawrence D'Oliveiro <l...@geek-central.gen.new_zealand> writes:
> > However, there are situations when you need thousands of lightweight
> > threads of execution ;;;
>
> The Linux kernel has been tested running hundreds of thousands of threads.

Those are still heavyweight threads requiring context switches to
switch from one to another. If you look at the multi-threading
benchmarks in the Alioth shootout, languages with lightweight threads
(such as Erlang or GHC) can switch orders of magnitude faster than
those that use kernel threads.

0 new messages