匡醍量化|大富翁量化

Python 3.14: Free Threading, Numpy 2.3, and the Rust Revolution

中文 📅 2025-07-15 👁 views this month —

The Python community has been buzzing with activity recently.

In mid-June, Python released Python 3.14 beta3. This is not an ordinary pre-release; it is the first version to officially support the long-awaited free threading, or "no GIL" (Global Interpreter Lock). The presence or absence of the GIL is undoubtedly a watershed moment in Python’s history.

This version is scheduled for release on this year’s Developers’ Day (October 24), bearing the magical number π as its version identifier.


No GIL, No Problem!

Python developers have long suffered under the constraints of the GIL. Because of this limitation, Python’s multithreading has often been more style than substance. Regardless of how powerful your laptop is, a multithreaded Python program will always face one core in distress while others watch—effectively utilizing only a single core.

tip

Removing the GIL comes at a cost. It reduces single-threaded performance by approximately 10% (or about 3% on Apple ARM architectures) and may increase memory overhead by 20%. Soon, we may see T-shirts sold with the slogan: "I Stand With GIL!"
## Numpy 2.3

Numpy is one of the most critical Python libraries. It recently released version 2.3 on July 12 to adapt to Python 3.14’s free-threading features. However, our testing indicates that you should not expect significant performance gains from this Numpy version, even when running on Python 3.14. Numpy has been GIL-free for a long time; therefore, when you submit Numpy-based computational tasks via ThreadPoolExecutor, that thread pool has effectively utilized your multi-core CPU for years. Thus, this Numpy update primarily enhances compatibility regarding free threading.

Consequently, for quantitative researchers, π-thyon may not immediately boost your program’s execution efficiency—if you have already fully leveraged vectorized operations from high-performance libraries like Numpy, Pandas, Polars, and DuckDB.

The true performance benefits of π-thyon may instead appear in web applications like Django. These typically consist of pure Python code and have historically been constrained by the GIL. To improve performance, these web frameworks often had to adopt multi-process architectures, which introduced additional performance overhead.

scikit-learn Now Supports GPU

Another noteworthy recent release is scikit-learn version 1.7. It now allows the use of CuPy or PyTorch tensors as data inputs and enables execution on GPUs. Of course, this release also signals that scikit-learn, a key member of the Python community, is now free-thread ready.

However, scikit-learn does not host overly complex models, so training remains fast regardless of whether you use GPUs or multithreading.

Ruff 0.12

If you are a serious developer, you have likely used various linting tools and complained about the speed of Black, Flake8, isort, and others. The current trend involves rewriting all these tools in Rust, which is exactly what Ruff aims to achieve.

Beyond Ruff, other tools rewritten in Rust include uv (planned to replace Poetry/pip-tools) and Pyrefly (replacing mypy and pyright). These projects suggest that 2025 may be remembered as the year when Rust-based Python tools transitioned from novelty to necessity.

However, since its version number is still so low, we might advise caution and let others test the waters first. After all, if Ruff produces false positives, spending time fixing a false report would be an intolerable error.