Python threads and Numeric/SciPy exploit Dual Core ?

Oeyvind Brandtsegg obrandts at
Mon Oct 2 13:32:39 CEST 2006

I've been trying to make my music app use dual core,
and would very much like some more detailed information on this.

Excuse my lack of knowledge,
but how do I explicitly release the GIL ?

I haven't learned this, but have found through experimentation that I
can release a thread by using time.sleep(0) inside a thread's "run
while true" loop. This seems to create an interrupt, and give other
threads a chance to do their thing.
If this is terribly wrong (it works, but I dont' know how stable it
is), please do point me in the direction of a proper way to implement
As stated in an earlier post, my threads do not work on shared data,
so I have not implemented any sort of lock or mutex.


On 10/2/06, Fredrik Lundh <fredrik at> wrote:
> "robert" wrote:
> > Simple Python code obviously cannot use the dual core by Python threads.
> > Yet, a program drawing CPU mainly for matrix computations - preferably
> > with Numeric/SciPy -  will this profit from a dual core when using 2 (or
> > more) Python threads?
> as long as the binding releases the GIL, sure.
> </F>
> --

More information about the Python-list mailing list