threading and multicores, pros and cons

MRAB google at mrabarnett.plus.com
Wed Feb 14 18:30:36 EST 2007


On Feb 14, 3:24 pm, garri... at gmail.com wrote:
> On Feb 13, 9:07 pm, Maric Michaud <m... at aristote.info> wrote:
>
> > I've heard of a bunch of arguments to defend python's choice of GIL, but I'm
> > not quite sure of their technical background, nor what is really important
> > and what is not. These discussions often end in a prudent "python has made a
> > choice among others"... which is not really convincing.
>
> Well, INAG (I'm not a Guru), but we recently had training from a Guru.
> When we brought up this question, his response was fairly simple.
> Paraphrased for inaccuracy:
>
> "Some time back, a group did remove the GIL from the python core, and
> implemented locks on the core code to make it threadsafe. Well, the
> problem was that while it worked, the necessary locks it made single
> threaded code take significantly longer to execute."
>
> He then proceeded to show us how to achieve the same effect
> (multithreading python for use on multi-core computers) using popen2
> and stdio pipes.
>
Hmm. I wonder whether it would be possible to have a pair of python
cores, one for single-threaded code (no locks necessary) and the other
for multi-threaded code. When the Python program went from single-
threaded to multi-threaded or multi-threaded to single-threaded there
would be a switch from one core to the other.




More information about the Python-list mailing list