Wheels for free-threaded Python now available
With the release of psutil 7.1.2, wheels for free-threaded Python are now available. This milestone was achieved largely through a community effort, as several internal refactorings to the C code were required to make it possible (see #2565). Many of these changes were contributed by Lysandros Nikolaou. Thanks to him for the effort and for bearing with me in code reviews! ;-)
What is free-threaded Python?
Free-threaded Python (available since Python 3.13) refers to Python builds that are compiled with the GIL (Global Interpreter Lock) disabled, allowing true parallel execution of Python bytecodes across multiple threads. This is particularly beneficial for CPU-bound applications, as it enables better utilization of multi-core processors.
The state of free-threaded wheels
According to Hugo van Kemenade’s free-threaded wheels tracker, the adoption of free-threaded wheels among the top 360 most-downloaded PyPI packages with C extensions is still limited. Only 128 out of these 360 packages provide wheels compiled for free-threaded Python, meaning they can run on Python builds with the GIL disabled. This shows that, while progress has been made, most popular packages with C extensions still do not offer ready-made wheels for free-threaded Python.
What it means for users
When a library author provides a wheel, users can install a pre-compiled binary
package without having to build it from source. This is especially important
for packages with C extensions, like psutil, which is largely written in C.
Such packages often have complex build requirements and require installing a C
compiler. On Windows, that means installing Visual Studio or the Build Tools,
which can take several gigabytes and a significant setup effort. Providing
wheels spares users from this hassle, makes installation far simpler, and is
effectively essential for the users of that package. You basically
pip install psutil and you’re done.
How to install free-threaded psutil
You can now install psutil for free-threaded Python directly via pip:
pip install psutil --only-binary=:all:
This ensures you get the pre-compiled wheels without triggering a source build.