To thread or not to thread

James Richards rootrot at govtabuse.com
Sat Jul 30 00:49:47 EDT 2005


On 2005-07-28, Sidd <iamsidd at gmail.com> wrote:
> Hello,
>       I was recently reading an article on threading in python and I
> came across Global Interpreter Lock,now as a novince in python I was
> cusrious about
>
> 1.Is writing a threaded code in python going to perform well than a
> normal python  code.If so on what basis can it performance be measured.

My last "real" experience with python threads was a while back, on a P-2.
That experience suggested that creating "lots" of threads (a few hundred)
caused some serious performance impacts.  I determined, in that instance,
that it was better to write my own implementation to simulate threads.
I had set of classes that pretended to be threads.  I had another class
which actually did all the threading for them.  It was pretty ugly.
>
> 2.Is writing a threaded code in python better than a code written in
> C/C++ using PTHREADS.

I agree with the earlier.  Define "better."  Do you really have a heavily
multi-threaded app?  Are these threads all CPU-intensive, or do you just 
have a bunch of threads which need some arbitrary scheduling?  Is it really
worth re-writing in PTHREADS?  Or could you buy a new server and save a few
months in development time by writing your own scheduling?

It all depends on your situation.

>
> If someone can comment on these questions, it would be great.
>

Heh.  You're on Usenet.  *Anyone* can comment on these questions.  :-)  
You should have asked for *useful* comments.  ;-)


-- 
Liberty means responsibility. That is why most men dread it.
- George Bernard Shaw




More information about the Python-list mailing list