Threads seem to be Evil

Hi,

From what I read, a lot of people believe that Threads are Evil. Guido van Rossum says that one should try to avoid threads as much as possible, because they make programs complex and they lead to deadlocks and race conditions. Some programs have been in production for over 4 years without any problem and suddenly they deadlock! It is incredibly difficult, even for simple multi-threaded programs, to think of every possible scenario. For more info, read this article:
http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf

Apparently the Stackless python implementation got rid of the GIL, but the overhead was 100%! In other words, programs ran twice as fast on the regular C python interpreter than on Stackless python (on a single CPU). This means that you only got some performance benefit out of Stackless python in heavily-multithreaded programs running on machines with 3 or more CPUs. Thus this project seems to have been abandonned. Guido van Rossum says that it is not worth the effort, and he definitely will not even try, but he still encourages anyone who has (a lot of) spare time to write a GIL-free python interpreter.

In the mean time, if you really want to take benefit of threads in multiple-CPU machines, you may use Jython (based on Java) or IronPython (based on .NET) which both rely on real threads.

Hope this helps

Reply

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.