<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/2.4.1" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>The Hand of FuManChu - Latest comments on Python concurrency syntax</title>
		<link>http://www.aminus.org/blogs/index.php?blog=2&#38;disp=comments</link>
		<description></description>
		<language>en-US</language>
		<docs>http://backend.userland.com/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=2.4.1"/>
		<ttl>60</ttl>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 23:52:57 +0000</pubDate>
			<dc:creator>admin [Member]</dc:creator>
			<guid isPermaLink="false">c38705@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Right; avoiding &quot;non-thread-safe&quot; collections is the purpose of the idea, and class/module/instance dicts are collections. Proposing that classes and modules be immutable is an attempt to maximize the volume of code that can be shared.&lt;br /&gt;
&lt;br /&gt;
And, yes, that would mean you can't say &quot;MyClass.foo = something&quot; outside of the class, at least not without an explicit &quot;monkey&quot; declaration either by the caller (user) or the callee (author) to mean, &quot;this attribute is now thread-global&quot;. That seems a horrible thing for a user to be able to do, until you realize they already do it (see the os.rmdir example above).&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Right; avoiding "non-thread-safe" collections is the purpose of the idea, and class/module/instance dicts are collections. Proposing that classes and modules be immutable is an attempt to maximize the volume of code that can be shared.<br />
<br />
And, yes, that would mean you can't say "MyClass.foo = something" outside of the class, at least not without an explicit "monkey" declaration either by the caller (user) or the callee (author) to mean, "this attribute is now thread-global". That seems a horrible thing for a user to be able to do, until you realize they already do it (see the os.rmdir example above).</p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38705</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 23:14:40 +0000</pubDate>
			<dc:creator>mike bayer [Visitor]</dc:creator>
			<guid isPermaLink="false">c38704@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;oh.  why not have &lt;strong&gt;dict&lt;/strong&gt; on classes/modules be marked as &quot;shareable&quot;? ?  other than you've now opened up a &quot;non-thread-safe&quot; collection....or is that the reason ?  &lt;br /&gt;
&lt;br /&gt;
also what does it really mean for class.&lt;strong&gt;dict&lt;/strong&gt; to be immutable...does it mean I cant say MyClass.foo = something outside of the &quot;class&quot; declaration itself ?&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>oh.  why not have <strong>dict</strong> on classes/modules be marked as "shareable"? ?  other than you've now opened up a "non-thread-safe" collection....or is that the reason ?  <br />
<br />
also what does it really mean for class.<strong>dict</strong> to be immutable...does it mean I cant say MyClass.foo = something outside of the "class" declaration itself ?</p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38704</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 22:44:40 +0000</pubDate>
			<dc:creator>admin [Member]</dc:creator>
			<guid isPermaLink="false">c38703@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Hi Mike,&lt;br /&gt;
&lt;br /&gt;
In my very humble musing, yes, each thread would get its own &quot;x&quot;, but only because the &quot;object&quot; to which the name &quot;x&quot; refers is a mutable object. If &quot;x&quot; referred to an immutable, all threads could share it without any further intervention. This is admittedly tricky with Python's dynamic typing, but I think this automatic creation of threadlocals would only have to occur for globals and object attributes (and possibly cell references), not locals, and not function arguments.&lt;br /&gt;
&lt;br /&gt;
I would imagine the copy would occur on the first get/set/del operation, just as it does for the current threading.local implementation.&lt;br /&gt;
&lt;br /&gt;
In this scheme, if you &lt;em&gt;don't&lt;/em&gt; make &lt;strong&gt;dict&lt;/strong&gt; on classes/modules immutable, you end up localizing almost everything; you might as well go with multiple processes at that point. Maybe I should run through Dejavu (and perhaps CherryPy) and put some numbers to these vague intuitions of mine... ;)&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Hi Mike,<br />
<br />
In my very humble musing, yes, each thread would get its own "x", but only because the "object" to which the name "x" refers is a mutable object. If "x" referred to an immutable, all threads could share it without any further intervention. This is admittedly tricky with Python's dynamic typing, but I think this automatic creation of threadlocals would only have to occur for globals and object attributes (and possibly cell references), not locals, and not function arguments.<br />
<br />
I would imagine the copy would occur on the first get/set/del operation, just as it does for the current threading.local implementation.<br />
<br />
In this scheme, if you <em>don't</em> make <strong>dict</strong> on classes/modules immutable, you end up localizing almost everything; you might as well go with multiple processes at that point. Maybe I should run through Dejavu (and perhaps CherryPy) and put some numbers to these vague intuitions of mine... ;)</p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38703</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 21:59:04 +0000</pubDate>
			<dc:creator>mike bayer [Visitor]</dc:creator>
			<guid isPermaLink="false">c38702@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Hi Robert -&lt;br /&gt;
&lt;br /&gt;
can you expound upon what the &quot;shared&quot; syntax would look like?  suppose I declare &quot;x=[]&quot; at the top of my module.  Now I use the &quot;thread&quot; module to run two threads, each using a worker function that randomly appends values to &quot;x&quot;.  How does the &quot;shared&quot; syntax prevent that list from being modified by both threads?  does &quot;x&quot; create copies of itself local to each thread when it detects a modify operation ?  how does making &lt;strong&gt;dict&lt;/strong&gt; on classes/modules immutable have anything to do with that (unless you mean, no more module-level globals or class-level variables )?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Hi Robert -<br />
<br />
can you expound upon what the "shared" syntax would look like?  suppose I declare "x=[]" at the top of my module.  Now I use the "thread" module to run two threads, each using a worker function that randomly appends values to "x".  How does the "shared" syntax prevent that list from being modified by both threads?  does "x" create copies of itself local to each thread when it detects a modify operation ?  how does making <strong>dict</strong> on classes/modules immutable have anything to do with that (unless you mean, no more module-level globals or class-level variables )?<br />
<br />
<br /></p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38702</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 21:54:14 +0000</pubDate>
			<dc:creator>admin [Member]</dc:creator>
			<guid isPermaLink="false">c38701@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Collin, could that not be solved with cooperative declaration between authors and users? You're right; allowing authors the sole power to @share would be to inter-thread sharing what Java's &quot;private&quot; modifier is to inter-class sharing--certainly not Pythonic. But in the cases where I've monkeypatched someone else's module, I would not have minded adding an explicit declaration to do so--in fact, I can see that being a beneficial construct for understanding and documentation:&lt;br /&gt;
&lt;br /&gt;
    import anotherlib&lt;br /&gt;
    &lt;br /&gt;
    with shared(anotherlib):&lt;br /&gt;
        anotherlib.os.rmdir = myrmdir&lt;br /&gt;
&lt;br /&gt;
...especially if the name is fairly easy to grep for. Maybe we could name it &quot;monkey&quot; instead of &quot;shared&quot;? ;)&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Collin, could that not be solved with cooperative declaration between authors and users? You're right; allowing authors the sole power to @share would be to inter-thread sharing what Java's "private" modifier is to inter-class sharing--certainly not Pythonic. But in the cases where I've monkeypatched someone else's module, I would not have minded adding an explicit declaration to do so--in fact, I can see that being a beneficial construct for understanding and documentation:<br />
<br />
    import anotherlib<br />
    <br />
    with shared(anotherlib):<br />
        anotherlib.os.rmdir = myrmdir<br />
<br />
...especially if the name is fairly easy to grep for. Maybe we could name it "monkey" instead of "shared"? ;)</p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38701</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 21:06:05 +0000</pubDate>
			<dc:creator>admin [Member]</dc:creator>
			<guid isPermaLink="false">c38700@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Doug, I realize Python is already used widely for large systems. I simply mean that when concurrency-aware code is mentioned, Erlang et al are mentioned far more often than Python.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Doug, I realize Python is already used widely for large systems. I simply mean that when concurrency-aware code is mentioned, Erlang et al are mentioned far more often than Python.<br />
<br /></p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38700</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 21:03:35 +0000</pubDate>
			<dc:creator>Collin Winter [Visitor]</dc:creator>
			<guid isPermaLink="false">c38699@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Any of the &quot;make such-and-such immutable&quot; ideas would greatly limit what I regard to be Python's greatest strength: testability. Currently I can manipulate a module's namespace to influence how it perceives (say) the os module, perhaps replacing rmdir() with a function that will test an otherwise-hard-to-test code path in my library.&lt;br /&gt;
&lt;br /&gt;
I wish people would just accept that threading is not one of Python's strengths and move on -- or better, write a decent interprocess queue so that MP code is easier.&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Any of the "make such-and-such immutable" ideas would greatly limit what I regard to be Python's greatest strength: testability. Currently I can manipulate a module's namespace to influence how it perceives (say) the os module, perhaps replacing rmdir() with a function that will test an otherwise-hard-to-test code path in my library.<br />
<br />
I wish people would just accept that threading is not one of Python's strengths and move on -- or better, write a decent interprocess queue so that MP code is easier.</p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38699</link>
		</item>
				<item>
			<title>In response to: Python concurrency syntax</title>
			<pubDate>Tue, 05 Jun 2007 21:02:12 +0000</pubDate>
			<dc:creator>Doug Napoleone [Visitor]</dc:creator>
			<guid isPermaLink="false">c38698@http://www.aminus.org/blogs/</guid>
			<description>&lt;p&gt;Question: What makes you think Python is not already big in the &quot;large systems&quot; space?&lt;br /&gt;
There are numerous examples of it already being there (Google, YouTube, SoE, DreamWorks, VMWare, EVE, etc, etc, etc, etc).&lt;br /&gt;
&lt;br /&gt;
I do believe that a strict 'thread private by default' system would be fantastic for python. My only concern would be for those of us who like python for prototyping, and implement in other languages. The GIL can be a stumbling block already, and  such a change would be a death blow to prototyping threaded systems for implementation in C++.&lt;br /&gt;&lt;/p&gt;
</description>
			<content:encoded><![CDATA[<p>Question: What makes you think Python is not already big in the "large systems" space?<br />
There are numerous examples of it already being there (Google, YouTube, SoE, DreamWorks, VMWare, EVE, etc, etc, etc, etc).<br />
<br />
I do believe that a strict 'thread private by default' system would be fantastic for python. My only concern would be for those of us who like python for prototyping, and implement in other languages. The GIL can be a stumbling block already, and  such a change would be a death blow to prototyping threaded systems for implementation in C++.<br /></p>
]]></content:encoded>
			<link>http://www.aminus.org/blogs/index.php/2007/06/05/python_concurrency_syntax?blog=2#c38698</link>
		</item>
			</channel>
</rss>
