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

Support free-threaded Python #3121

Open
ngoldbaum opened this issue Feb 6, 2025 · 1 comment
Open

Support free-threaded Python #3121

ngoldbaum opened this issue Feb 6, 2025 · 1 comment

Comments

@ngoldbaum
Copy link

ngoldbaum commented Feb 6, 2025

It should be possible to use SWIG to build a Python C extension for use with the free-threaded build of CPython.

I'm working at Quansight Labs along with a small team to improve ecosystem support for free-threaded Python. We've put together some documentation that is a good place to start: https://py-free-threading.github.io.

One big wrinkle that might come up is that free-threaded 3.13 (and maybe 3.14) won't support the limited API, so free-threaded extensions must use the version-specific ABI.

When we added free-threading support in other wrapper tools like Cython, PyO3, and F2Py the job of adding free-threaded support was first to make sure generated wrapping code is thread-safe. Once that's done, there needs to be a way for the extension author to signal that they think the extension is thread-safe.

@wsfulton
Copy link
Member

wsfulton commented Feb 7, 2025

Your link led me to Quansight Labs blog post about work on free-threading and it looks like a great initiative. Indeed it should be possible for the code that SWIG generates to support free-threaded Python.

Given SWIG generates bindings for hundreds of Python extensions, it makes sense for SWIG to be involved. Good to have a heads up of this initiative and we can do what we can to help. Just so that you know, the SWIG developers are struggling to keep up with patches and necessary improvements and if Quansight Labs can assist, as you do other Python open source projects, it would certainly help the wider Python ecosystem and free-threaded Python stability. The most beneficial thing would be to find an advanced C Python API expert who can join the SWIG developer community to manage patches/pull requests and make other improvements into the SWIG code base. I say this as the SWIG developers are volunteers, are very few and without a sponsored SWIG developer, we're never going to keep up. Feel free to contact me offline or discuss further here if you feel Quansight can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants