Microthreads without Stackless?

Bryan Olson fakeaddress at nowhere.org
Thu Sep 16 01:25:00 EDT 2004


M.E.Farmer wrote:
 > Wow!,
 >     Provocative = Tending to provoke or stimulate.
[...]
 > I noticed you tend to be quite critcal of others.

I noticed you take no interest in whether criticism
is valid.

 > Did you notice the OP asked for:
 >     microthreads
 >     using generators and threads
 >     The devil, however, is in the scheduler's details

Absolutely.  And I followed up your post that said Mertz
covered this.

 > What I posted was about as close as you get.
 >     'Implementing "weightless threads" with Python generators.'
 >     I have not studied or used that code.
 >     I hoped it would be of use as inspiration for his scheduler.
 >     If nothing else it would show how not to do it.
 >     Mertz never said they were like real threads or coroutines.
 >     Where did you get that?
 >     I know it breaks your heart there aren't coroutines in Python.
 >     But get a grip on reality.

Hold, on, let me see ... you have an actual technical
disagreement with my saying Mertz was wrong, specifically you
say, "Mertz never said they were like real threads or
coroutines". Mertz wrote:

     These are not true coroutines in the sense that control
     only branches to and from the scheduler() function, but for
     practical purposes, one accomplishes the same thing with
     very little extra code.

Mertz certainly is saying they are like co-routines, and he
seems to think the major difference is in the scheduler.  I
think he's wrong: the key difference is switching from anywhere,
not just one-call-down.

 >     I know it breaks your heart there aren't coroutines in Python.

Kind of.  I haven't lost hope.  In addition to the Python
extensions, the Perl 6 project is designing the interpreter so
it can support multiple languages, specifically including
Python.  It may become a compelling platform, enabling Perl,
Python and Ruby to share libraries, and providing continuations
and co-routines in the deal.


 >     We have got generators(semi-coroutines),
 >     and others have mentioned it **is** doable.

Another technical point, but here I'm not sure what 'it' refers
to.

 >>Well, the Erlang (language + telecom platform) uses light-weight
 >>threads which could e.g. be implemented with coroutines in Python.
 >
 > Bryon wrote:
 > Well, the issue here is whether they could be implemented
 > reasonably in Python as it currently is, with generators
 > but not co-routines.
 > """
 > Why didn't you post a link to the other thread?

First, I thought I could make the point more clearly here.
Second, I found that thread hard to follow, because the OP's
replies kept appearing threaded under the first post.

 > Did you notice the other people that responded are the ones
 > from the other thread?

Uh, somewhat.  In that thread, a number of people made the key
point: the major difference between generators and co-routines is
that co-routines can switch at any call-depth.

 > Since you gave me your opinion I will share mine. [...]

Mine were technical.  Yours are personal.


-- 
--Bryan



More information about the Python-list mailing list