[Python-Dev] Find out whether PyEval_InitThreads has been called? (original) (raw)
Gustavo J. A. M. Carneiro gjc at inescporto.pt
Mon Aug 16 12:43:09 CEST 2004
- Previous message: [Python-Dev] Find out whether PyEval_InitThreads has been called?
- Next message: [Python-Dev] Decorator syntax J2 (decorate..def), with implementation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
A Seg, 2004-08-16 às 11:35, Gustavo J. A. M. Carneiro escreveu:
Short version:
Can I add a variable to python to indicate whether PyEvalInitThreads has been called? Something like: extern int PyEvalThreadsInitialized; 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?
Forget it. Why not go one step further and make all locking operations in python no-ops if PyEval_InitThreads has never been called? Currently, we risk python crashing if we call such functions without calling PyEval_InitThreads. This is also trivial to implement.
Regards.
-- Gustavo J. A. M. Carneiro <gjc at inescporto.pt> <gustavo at users.sourceforge.net> The universe is always one step beyond logic
- Previous message: [Python-Dev] Find out whether PyEval_InitThreads has been called?
- Next message: [Python-Dev] Decorator syntax J2 (decorate..def), with implementation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]