diff --git a/src/zope/interface/_compat.py b/src/zope/interface/_compat.py index bc3f8671..f6a95581 100644 --- a/src/zope/interface/_compat.py +++ b/src/zope/interface/_compat.py @@ -74,8 +74,10 @@ def _should_attempt_c_optimizations(): """ Return a true value if we should attempt to use the C optimizations. - This takes into account whether we're on PyPy and the value of the - ``PURE_PYTHON`` environment variable, as defined in `_use_c_impl`. + This takes into account whether we're on PyPy, whether you're using + a freethreading version of Python 3.13+ (where importing + the speedups would enable GIL) and the value of the ``PURE_PYTHON`` + environment variable, as defined in `_use_c_impl`. """ is_pypy = hasattr(sys, 'pypy_version_info') @@ -83,6 +85,8 @@ def _should_attempt_c_optimizations(): return True if is_pypy: return False + if sys.version_info >= (3, 13) and not sys._is_gil_enabled(): + return False return not _c_optimizations_ignored()