GIL cpu multi core usage problem

Gabriel Genellina gagsl-py2 at
Wed Jun 11 03:52:31 CEST 2008

En Mon, 09 Jun 2008 15:26:09 -0300, Pau Freixes <pfreixes at>  

> Surly this is a recurring theme into python dev world, but I need your  
> help
> for confirm if the follow image it's really
> I'm writing a brief article for my blog and I need to make sure about the
> current problem with GIL and multi core environments, this picture try to
> explain with images the problem for scheduling multiple threads running
> python code of same interpreter into multiple cpu cores. Can  anyone  
> confirm
> to me this picture ?

Yes, if both threads are executing pure Python code, they can't run  

Note that:
- C extensions (usually) release the GIL when they don't call into any  
Python code
- The interpreter also releases the GIL before any I/O operation
If the process is I/O bound then the GIL is not so important, and if it's  
CPU bound you may benefit from reimplementing the critical parts in C (by  
example, using NumPy for a number-crunching process). Another alternative  
is to use multiple processes with some form of IPC instead of multiple  
These are the usual arguments against "fear of GIL". You should consider  
your specific application to see if the GIL is actually a problem in your  
case or not.

Gabriel Genellina

More information about the Python-list mailing list