<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><meta http-equiv="x-dns-prefetch-control" content="off"></div><div id="yiv1779067564"><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: times new roman,new york,times,serif; font-size: 12pt;"><div id="yiv1779067564yui_3_2_0_15_131689318280948"><span id="yiv1779067564yui_3_2_0_15_131689318280977">Hi Armin and Folks:<br id="yiv1779067564yui_3_2_0_15_1316893182809440"></span><span></span></div><div id="yiv1779067564yui_3_2_0_15_1316893182809447"><br id="yiv1779067564yui_3_2_0_15_131689318280951"></div><div class="yiv1779067564yui_3_2_0_15_131689318280952" id="yiv1779067564yui_3_2_0_15_131689318280954" style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div id="yiv1779067564yui_3_2_0_15_131689318280980" class="yiv1779067564yui_3_2_0_15_131689318280957"
 style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font id="yiv1779067564yui_3_2_0_15_131689318280988" face="Arial" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Armin Rigo &lt;arigo@tunes.org&gt;<br><b><span style="font-weight: bold;">To:</span></b> Александр Седов &lt;elec.lomy.ru@gmail.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> pypy-dev@python.org<br><b id="yiv1779067564yui_3_2_0_15_131689318280994"><span id="yiv1779067564yui_3_2_0_15_131689318280993" style="font-weight: bold;">Sent:</span></b> Friday, September 23, 2011 4:38 PM<br><b id="yiv1779067564yui_3_2_0_15_131689318280987"><span id="yiv1779067564yui_3_2_0_15_131689318280986" style="font-weight: bold;">Subject:</span></b> Re: [pypy-dev] Stacklets<br></font><br>&gt;Thanks!&nbsp; Work in this direction is already well advanced.&nbsp; More<br>&gt;precisely, the directory pypy/module/_stackless is obsolete and
 gone,<br>&gt;and the pure Python module lib_pypy/stackless.py has been ported to<br>&gt;use _continuation.&nbsp; (I wonder somehow why we had all this code in<br>&gt;pypy/module/_stackless that seems not needed any more.)<br><br>I downloaded the latest build&nbsp; looked at stackless.py and wrote a simple test. When I have<br>time, I will try incorporate and test my new (and very unofficial) stackless features. I also
 should<br>have enough code to run weird examples that ought to stress the system.<br><br>That said, I'm really impressed that continulets was ported so fast. Kudos to Rodrigo! A <br>suggestion. Perhaps it would be good to keep the test for whether CPython is the interpreter and greenlets<br>ought to be used? In this fashion, someone that does want to use pypy-c can still play with stackless. And<br>one authoritative copy of stackless.py can be kept (as opposed to hacking a version for greenlets).<br><br>&gt; But it is not multi-thread-safe so far, which is probably an easy fix, using a<br>&gt;thread-local instead of all these global variables initialized in<br>&gt;_init() in stackless.py.<br><br>In the stackless mailing list, there is a conversation about some gotchas concerning threads and<br>tasklets that one may want to read. Although the conversation revolves around C Stackless Python<br>based internals, the 50000ft view is about threads dying with
 tasklets binded to them.<br><br>&gt;So far you can pickle continulets, greenlets, and coroutines, but
 not<br>&gt;tasklets.&nbsp; It looks messy because of early-optimization issues from<br>&gt;stackless.py .<br><br>All I know about pickling is that one cannot pickle a tasklet with cstate. Or a blocked tasklet.<br>I don't know how that translates into the pypy world. <br><br>&gt;--- e.g. it would be much more natural for it to switch<br>&gt;to the main tasklet every time it needs to do the scheduling and<br>&gt;choose the next tasklet to switch to, instead of being clever and<br>&gt;switching directly to the target tasklet; this "unwanted cleverness"<br>&gt;prevents pickling from working at all, because it sees too much<br>&gt;unrelated stuff in a suspended tasklet<br><br>This makes the scheduler sound like a generator trampoline. Also <br>adds an additional context switch, if I understand things correctly.<br><br>&gt;All in all what I would be most happy with, at this point, is if<br>&gt;someone would step up and finish porting and maintaining
 stackless.py.<br> &gt;Ideally it would be someone that needs this code for his own<br>&gt;projects, too.<br><br>Seems that Rodrigo did a pretty good job. What is left to be done?<br><br>Cheers,<br>Andrew<br></div></div></div></div><div><meta http-equiv="x-dns-prefetch-control" content="on"></div></div></body></html>