Re: To thread or not to thread
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Thu, 28 Jul 2005 20:53:30 -0000
On 2005-07-28, Sidd <iamsidd@xxxxxxxxx> wrote:
> 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.
It's sort of a corrolary to Amdahls law: on a single CPU
machine, optimally written multi-threaded code will always
perform worse than optimally written single-threaded code.
[Where performance is in terms of CPU efficiency.]
However, it may be very difficult to write optimal
single-threaded code, and much easier to write (nearly) optimal
multi-threaded code. So, in practice, multi-threaded code
often performs better for certain classes of problems.
> If so on what basis can it performance be measured.
That's up to whoever is doing the measuring.
> 2.Is writing a threaded code in python better than a code
> written in C/C++ using PTHREADS.
Define "better".
On a multi-CPU machine you can get much more parallelism for
compute-intensive tasks using C/pthreads than you can using
Python threads.
It's also a lot easier to write buggy code containing race
conditions using C/pthreads.
--
Grant Edwards grante Yow! I want to read my new
at poem about pork brains and
visi.com outer space...
.
- References:
- To thread or not to thread
- From: Sidd
- To thread or not to thread
- Prev by Date: Re: Determine if object is a Bound or Unbound method
- Next by Date: Re: On fighting fire with fire...
- Previous by thread: To thread or not to thread
- Next by thread: pySerial Windows write problem
- Index(es):