To thread or not to thread

snacktime snacktime at gmail.com
Sat Jul 30 05:08:03 EDT 2005


On 28 Jul 2005 12:10:12 -0700, 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.
> 
> 2.Is writing a threaded code in python better than a code written in
> C/C++ using PTHREADS.
> 
> If someone can comment on these questions, it would be great.
> 

If you want performance with an application that does a lot of
concurrent activity, you might take a look at
http://www.twistedmatrix.com which is an event driven framework for
python.
Much better performance than threads with a lot less memory and cpu
usage.  Although it does have a bit of a learning curve.  In my own
experience it would be faster  then a comparable application written
in C using pthreads.  We have an application written in twisted that
processes financial applications via bank networks, and at a steady
100tps I get about 1% cpu usage.   We tested it up to around 1000tps
before our database server started to get a bit overloaded.  Twisted
never used more than 20% of the cpu though.

Chris



More information about the Python-list mailing list