Fundamentals 18 min read

Can Python Run Without the GIL? Inside the nogil Project and Its Challenges

This article summarizes Sam Gross’s nogil project—a Python 3.9 fork that removes the GIL—detailing its design changes, early benchmarks, integration challenges, and the community’s discussion on feasibility, performance, and the roadmap toward a GIL‑free CPython.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Can Python Run Without the GIL? Inside the nogil Project and Its Challenges

Brief Summary

Sam Gross’s nogil project demonstrates that removing the GIL from Python 3.9 is technically possible, yielding a modest performance gain and better scalability, but merging it into CPython requires extensive work and a migration plan.

Introducing nogil

Key design changes include replacing pymalloc with mimalloc, using biased reference counting, lock‑free dictionary reads, a single‑threaded stop‑the‑world garbage collector, moving the MRO cache to thread‑local storage, and making built‑in collection types thread‑safe.

Early Benchmarks

On the pyperformance suite the nogil interpreter is about 10 % faster than CPython 3.9, and the full set of changes (without removing the GIL) could give a 19 % boost, though multicore scalability remains limited. CPython 3.11 is about 16 % faster than nogil in single‑threaded tests.

Key Questions from the Sprint

Risks include ensuring C extensions work correctly and providing a smooth migration path for the community.

Integration will likely happen incrementally on the 3.9 branch before being back‑ported to the main (3.11) branch.

Adopting the register‑based VM and other optimisations is essential for performance.

Support for C extensions may require new APIs or runtime flags such as -X nogil.

Long‑term plans consider a gradual phase‑out of the GIL, possibly with multi‑interpreter support.

Next Steps

The core team plans to experiment with integrating mimalloc (see CPython pull #29123) and to continue evaluating the feasibility of upstreaming nogil.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performancePythonconcurrencyGILinterpreterCPythonnogil
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.