Lambda the Ultimate

inactiveTopic Implementing "weightless threads" with Python generators
started 6/10/2002; 5:08:06 AM - last post 6/10/2002; 5:08:06 AM
Ehud Lamm - Implementing "weightless threads" with Python generators  blueArrow
6/10/2002; 5:08:06 AM (reads: 1951, responses: 0)
Implementing "weightless threads" with Python generators
(via Daily Python-URL)

In a way, weightless threads recall the cooperative multitasking of older Windows and MacOS versions (but within a single application). In another sense, however, weightless threads are merely another way of expressing flow in a program; everything that weightless threads do could, at least in principle, be accomplished with the "really big if/elif block" technique (the last resort of the brute-force programmer).

Essentially a trampoline that passes control from generator to generator.

The technique should be well-known to anyone who has seen how you implement multi-threading using continuations.

Still, a nice demonstration of the power of Python, and a way to familiarize youself (or a friend) with continuations.


Posted to Python by Ehud Lamm on 6/10/02; 5:08:42 AM