[Numpy-discussion] Python global interpreter lock ...

Konrad Hinsen hinsen at cnrs-orleans.fr
Tue May 6 03:27:04 CDT 2003


On Wednesday 30 April 2003 08:47, Andrew P. Lentvorski, Jr. wrote:

> 1) Does numpy (or numarray) release the Python GIL?

No.

> 2) If not, why not?  Is this simply something I could fix by making the
> changes myself, or are there larger reasons for not releasing the GIL?

There is one good reason, which is that the GIL release code doesn't nest. If 
NumPy released the GIL during its operations, then any C code that uses NumPy 
functions would have to reacquire the GIL before calling NumPy, then 
re-release the GIL afterwards. In most real-life situations, it is simpler 
and presumably more efficient to release the GIL once for a block of 
numerical computations, which would include many calls to NumPy functions.

One could of course release the GIL not within the functions that are part of 
the NumPy C API, but in a thin wrapper around it that is directly called from 
Python.

The only other problem that I see is the general object type arrays, which 
make calls back into the Python interpreter.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------





More information about the Numpy-discussion mailing list