[Stackless] PyCon 2011 Talk Acceptence and Questions on Greenlets

Jeff Senn senn at maya.com
Fri Jan 14 15:40:46 CET 2011


On Jan 13, 2011, at 10:15 PM, Richard Tew wrote:

> On Fri, Jan 14, 2011 at 1:59 AM, Andrew Francis <andrewfr_ice at yahoo.com> wrote:
>> Richard I am researching how greenlets work. A part of this is actually looking at the code with a debugger. However I do not see a problem with also asking questions and starting a conversation on this otherwise quiet mailing list. If anyone can provide insights, that would be great. I guess that I am interested in is that I do not see the any alteration to ceval.c. I need to understand more about what is on the C stack to move beyond a superficial understanding of hard switching. I am interested in part because I want to see if this technique can be extended to PyPy-C.
> 
> Think of soft switching like getting the Python interpreter to switch
> what Python code it is executing.  And hard switching like getting the
> processor the Python interpreter is running on to switch what assembly
> instructions it is executing.  For the former, you much around with
> ceval and Python frames.  For the latter you just put new values into
> the PC and SP registers - it is that simple.

An addition to this -- lest you think:
"why would I ever do soft-switching?!  It seems complicated and that 
hard-switch seems simple and fast!"

You also, with hard-switching, have to copy (and save/restore) the 
contents of the processor stack.  And in many instances that (structurally
simple, but possibly quite large) memory copy/restore operation 
can be MUCH slower than the few (complicated) extra calls involved 
in a soft-switch (it will probably flush out the memory cache of 
your processor for instance... if you know about such things...)

So that might explain why someone (Christian) went to great trouble
to mung with the internals of ceval.c.

Hope this helps (eventually) and doesn't just cloud the issue.

> I hope that clears up the misconception you have above.
> 
> Cheers,
> Richard.
> 
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
> 




More information about the Stackless mailing list