[Python-ideas] New PEP proposal: C Micro-Threading (ala Twisted) (long!)

Bruce Frederiksen dangyogi at gmail.com
Mon Aug 4 01:55:25 CEST 2008

Yes, the greenlet package is available for current Python
releases, but there is a note that it doesn't work "out of the box"
on the Win32 platform.

The greenlet package uses much the same approach as the
second incarnation of stackless -- it copies the C stack.  This
limits portability to different CPU/C compiler architectures (I'm
not sure if this is why it doesn't work on Win32).

It also lacks a reactor, though one could be written for it.

I don't believe that it has an alternate main loop, but that it copies
the C stack between calls to greenlet.switch.  Each copy is retained
in the heap making it available to be copied back to the C stack
when it becomes the target of another greenlet.switch.

Josiah Carlson wrote:
> A few comments...
> Firstly, this is a great PEP, you've obviously put a lot of thought
> and effort into getting it together.
> Secondly, isn't the greenlet package already available online for
> current Python revisions?  If so, has it gained significant numbers of
> users?
> Regardless of the answer to the above, how does the current greenlet
> package plug into Python without having API hooks?  Does it execute an
> alternate mainloop that does the stack switching?
>  - Josiah
> P.S. After having used event-driven frameworks for quite a few years
> (asyncore derived socket servers and clients, wxPython,
> publish/subscribe architectures, ...), they really aren't all that
> bad.  Then again, I don't find threading all that bad either (I try to
> stick with simple queues, explicitly synchronized interfaces, etc.,
> which reduces complexity by a few orders of magnitude).

More information about the Python-ideas mailing list