basic thread question

Derek Martin code at pizzashack.org
Tue Aug 18 18:18:54 EDT 2009


On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote:
> I have some simple threaded code...  If I run this
> with an arg of 1 (start one thread), it pegs one cpu, as I would
> expect.  If I run it with an arg of 2 (start 2 threads), it uses both
> CPUs, but utilization of both is less than 50%.  Can anyone explain
> why?  
 
Ah, searching while waiting for an answer (the e-mail gateway is a bit
slow, it seems...) I discovered that the GIL is the culprate.
Evidently this question comes up a lot.  It would probably save a lot
of time on the part of those who answer questions here, as well as
those implementing solutions in Python, if whoever is maintaining the
docs these days would put a blurb about this in the docs in big bold
letters...  Concurrency being perhaps the primary reason to use
threading, essentially it means that Python is not useful for the
sorts of problems that one would be inclined to solve they way my code
works (or rather, was meant to).  It would be very helpful to know
that *before* one tried to implement a solution that way... especially
for solutions significantly less trivial than mine. ;-)

Thanks

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090818/07cddc87/attachment.sig>


More information about the Python-list mailing list