I'm writing a multi-threaded Python application, which will behave differently on systems, depending on the details of the GIL implementation.
Is there a general purpose way for me to test whether the intepreter I'm running on has a CPython style GIL?
No, the stdlib has no API or flag to test for the GIL. For now you can safely assume that all versions of CPython and PyPy have a GIL while IronPython and Jython don't have a GIL.
Python 3.3 and newer have
sys.implementation.name
. In older versions you can useplatform.python_implementation()
.