[Python-Dev] Find out whether PyEval_InitThreads has been called?

Gustavo J. A. M. Carneiro gjc at inescporto.pt
Mon Aug 16 12:35:33 CEST 2004


Short version:

  Can I add a variable to python to indicate whether PyEval_InitThreads
has been called?  Something like:

	extern int PyEval_ThreadsInitialized;

Motivation:

  I have discovered that, in pygtk, performance decreases a lot (50-90%
higher exectution time) when we use python locking.  We have an internal
boolean flag in pygtk to indicate whether pygtk threading was enabled or
not, thus avoiding the GIL locking functions in single threaded
programs.

  The problem is that this flag is local to pygtk.  If another module
activates threading in python, we would like to know it in order to
start acquiring the GIL.

  This should be a very simple patch, with zero impact in python core,
but it will help tremendously.  Is likely to be accepted for python 2.4?

  Regards.

PS: I already asked python-help about this, sorry for the duplicate
mails.

-- 
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic



More information about the Python-Dev mailing list