[Python-ideas] PEP draft - Composable futures for reactive programming

Antoine Pitrou solipsis at pitrou.net
Sun Dec 22 15:54:15 CET 2013


On Sat, 21 Dec 2013 20:01:26 -0800
Guido van Rossum <guido at python.org> wrote:

> On Sat, Dec 21, 2013 at 7:53 PM, Chris Angelico <rosuav at gmail.com> wrote:
> > On Sun, Dec 22, 2013 at 2:45 PM, Guido van Rossum <guido at python.org> wrote:
> >> To cut through that you'd have to have
> >> some kind of stack-swapping coroutine implementation like gevent...
> >
> > Forgive the stupid question, but how is stack-swapping during blocking
> > calls materially different from threads?
> 
> It's also known as "green threads". The gevent folks and the Stackless
> folks (and a few others) do this and claim it is vastly superior to OS
> threads. I believe the main difference is that an OS thread takes up a
> relatively large amount of resources in the kernel as well as in user
> space (for the stack) while a green thread takes up a comparatively
> much smaller amount of space, all in user space -- with the result
> that you can have many more green threads than you could have OS
> threads, and switching between them will be much faster.

Also, in Python 2.x, it avoids the contention cost of the GIL with many
OS threads (cf. the Dave Beazley benchmark :-)).

Regards

Antoine.




More information about the Python-ideas mailing list