Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Do not use C speedups on Python 3.13+ freethreading #331

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
7.1.1 (unreleased)
==================

- Disable automatically using C speedups when Python 3.13 is used
in freethreading mode for the time being (at least until the C
extension gains support for freethreading mode).
(`#330 <https://github.com/zopefoundation/zope.interface/issues/330>`_)

- Fix segmentation faults in `weakrefobject.c` on Python 3.12 and 3.13.
(`#323 <https://github.com/zopefoundation/zope.interface/issues/323>`_)

Expand Down
8 changes: 6 additions & 2 deletions src/zope/interface/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ 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')

if _c_optimizations_required():
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()


Expand Down
Loading