Re: To thread or not to thread



On 28 Jul 2005 12:10:12 -0700, Sidd <iamsidd@xxxxxxxxx> 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
.



Relevant Pages

  • Re: dual processor
    ... Python was never designed to be a high performance ... And as a result I want concurrency easy to deal with, ... > goes up, and the price per CPU in a single system goes down, the ability ... > Steve's magical thinking programming language will have a ton of merit. ...
    (comp.lang.python)
  • Re: Parallel Python
    ... |> In any case, this means that Python can happily keep its GIL, as the ... |> I wonder if too much emphasis is put on thread programming these days. ... |> numerical tasks on computers with multiple CPUs (or multiple CPU ... murder to produce a Python binding that had any hope of delivering ...
    (comp.lang.python)
  • Re: Python advocacy in scientific computation
    ... I believe one can run separate Python processes on separate cores just as well as one can run separate processes on separate chips or separate machines. ... to use more than one core for CPU intensive tasks. ... in competing languages, this might well be the weak point of Python ...
    (comp.lang.python)
  • Re: Will Python 3.0 remove the global interpreter lock (GIL)
    ... performance than a GIL CPython implementation of the late 1990's. ... network bandwith have increased by a much larger factor than CPU speed ... If Python was just fast enough to firewall your T1 net ... with other languages if the other languages keep up with developments ...
    (comp.lang.python)
  • Re: Dedicated CPU core for Python?
    ... CPU core right now because it's threads are all internal, ... Yes, that may be, but they are not true system threads, or at least do not ... have several threads in my Python program, ... But, because the CPython system isn't really reentrant, most of the ...
    (comp.lang.python)