threading support in python

Steve Holden steve at holdenweb.com
Tue Sep 5 02:49:44 EDT 2006


Sandra-24 wrote:
[Sandra understands shared memory]
> 
> I would find an easier time, I think, porting mod_python to .net and
> leaving that GIL behind forever. Thankfully, I'm not considering such
> drastic measures - yet.
> 
Quite right too. You haven't even sacrificed a chicken yet ...

> Why on earth would I want to do all of that work? Just because you want
> to keep this evil thing called a GIL? My suggestion is in python 3
> ditch the ref counting, use a real garbage collector, and make that GIL
> walk the plank. I have my doubts that it would happen, but that's fine,
> the future of python is in things like IronPython and PyPy. CPython's
> days are numbered. If there was a mod_dotnet I wouldn't be using
> CPython anymore.
> 
You write as though the GIL was invented to get in the programmer's way, 
which is quite wrong. It's there to avoid deep problems with thread 
interaction. Languages that haven't bitten that bullet can bite you in 
quite nasty ways when you write threaded applications.

Contrary to your apparent opinion, the GIL has nothing to do with 
reference-counting.
> 
>>Now, the GIL is independent of this; if you really need threading in
>>your situation (you share almost everything and have hugely complex
>>data structures that are difficult to maintain in shm) then you're
>>still going to run into GIL serialization.  If you're doing a lot of
>>work in native code extensions this may not actually be a big
>>performance hit, if not it can be pretty bad.
> 
> 
> Actually, I'm not sure I understand you correctly. You're saying that
> in an environment like apache (with 250 threads or so) and my hugely
> complex shared data structures, that the GIL is going to cause a huge
> performance hit? So even if I do manage to find my way around in the
> Linux world, and I upgrade my memory, I'm still going to be paying for
> that darned GIL?
> 
I think the suggestion was rather that abandoning Python because of the 
GIL might be premature optimisation. But since you appear to be sticking 
with it, that might have been unnecessary advice.

> Will the madness never end?

This reveals an opinion of the development team that's altogether too 
low. I believe the GIL was introduced for good reasons.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list