PEP 703 -- Making the Global Interpreter Lock Optional in CPython #108219
Labels
3.13
bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-free-threading
type-feature
A feature request or enhancement
Feature or enhancement
The steering council has accepted PEP 703. This is intended as a top-level issue to keep track of integration status.
The "up for grabs" list contains issues that no one is currently working on and are ready to be implemented. If you are interested in working on one of them, please comment on the specific issue and CC me (@colesbury) on related PRs.
Up For Grabs (comment on specific issue to take)
Linked issues
--disable-gilbuilds are not compatible with the limited API #111506--disable-gilbuilds install incompatible stable ABI extensions #111870--disable-gilbuilds #115999--disable-gil builds#116024_thread.lock.release()is not thread-safe in free-threaded builds #117721list.__getitem__#119053Completed Issues
Completed Issues
--disable-giloption for Windows builds #108374ATTACHED,DETACHED,GCtoPyThreadStateto support PEP 703 #109549--disable-gilbuilds #109740--disable-giltest failures due to ABI flag #110119--disable-gilbuilds (PEP 703) in packaging.tags pypa/packaging#727_structmodule thread-safe in--disable-gilbuilds #112062Py_BEGIN_CRITICAL_SECTION()) #111903functools.lru_cachethread-safe in--disable-gilbuilds #112070--disable-gilbuilds) #111965@critical_sectiondirective #112213random.Randomthread-safe in--disable-gilbuilds #112071--disable-gilbuilds #111972_PyThreadStateImpl"wrapper" forPyThreadState#112538--disable-gilbuilds #111962_Py_ThreadId()work on PowerPC, IBM Z, etc. #112535_PyUnicode_FromIdthread-safe in--disable-gilbuilds #111971--disable-gilbuilds) #111964--disable-gilbuilds #113884PyList_GetItemRef, a variant ofPyList_GetItemthat returns a strong reference #114329PyDict_SetDefaultthat returns a new reference (instead of a borrowed reference) #112066--disable-gilbuilds #110481--disable-gilbuilds #112532--disable-gilbuilds #112050--disable-gilbuilds #111968ob_tid,ob_ref_local, andob_ref_sharedfields valid across allocations in free-threaded build #115491eval_breakertoPyThreadState#112175listobjects thread-safe in--disable-gilbuilds #112087defaulttimeoutin free-threaded build #116616--with-thread-sanitizer#112536_warnings.cthread-safe in free-threaded build #116664cellthread-safe in the free-threaded build #117323sys._current_frames()andsys._current_exceptions()thread-safe in free-threaded build #117300SemLockthread-safe in the free-threaded build #117435_threadmodule.cthread-safe in--disable-gilbuilds #114271setthread-safe in--disable-gilbuilds #112069sys.settrace,sys.setprofile, andsys.monitoringthread safe in--disable-gilbuilds #116818sys._is_gil_enabled()#117514--disable-gilbuilds #112529dictobjects thread-safe in--disable-gilbuilds #112075Deferred tasks
Upstream functionality from nogil-3.12
This is a list of commits from the nogil-3.12 PR plan. The crossed-out entries are commits that do not need to be upstreamed, usually because the functionality is already in the main branch.
cefe5dfee9configure: disallow "--with-trace-refs" for "--disable-gil" buildsdcddbe2ddbconfigure: add support for --with-thread-sanitizer (Add support for thread sanitizer (TSAN) via--with-thread-sanitizer#112536)f546dbf16aEnable/disable the GIL at runtime (Add a mechanism to disable the GIL #116167)f30d8d8f50Add pyatomic.h385eb1d99cpyport: add new macrosde2be447b3Make PyThreadState_GET thread-locala24dc2ecc3pystate: keep track of attached vs. detached state4584be5950parking_lot: add mutexes and one-time notifications6845b133cccritical_section: helpers for fine-grained locking (Implement Python Critical Sections from PEP 703 #111569)8ed62cab6apystate: use _PyRawMutex for internal mutexes (Avoid changing the PYMEM_DOMAIN_RAW allocator during initialization and finalization #111924)e15443b1f2ceval: move eval_breaker to per-thread state (Move theeval_breakertoPyThreadState#112175)b6b12a9a94Implement biased reference countingb6b12a9a94Implement BRC inter-thread queue (Implement biased reference counting in--disable-gilbuilds #110481)7b6b6f1a01unicode: immortalize interned stringsfc173e3711unicode: always immortalize interned stringsdd9b78460cAdd safe memory reclamation scheme based on FreeBSD's GUS901e134921Add mimalloc v2.0.9 (DinoV)b6980856dfAdditional mimalloc changes (mimalloc: additional integration and changes for--disable-gilbuilds #112532)d13c63dee9pymem: remove uses of _PyMem_SetDefaultAllocator during finalization (Avoid changing the PYMEM_DOMAIN_RAW allocator during initialization and finalization #111924)654be8ffd6gc: make the garbage collector non-generational (Make the garbage collector thread-safe in--disable-gilbuilds #112529)967fe31473gc: Traverese mimalloc heaps to find all objects. (Make the garbage collector thread-safe in--disable-gilbuilds #112529)2864b6b36eImplement stop-the-world pauses (Implement stop-the-world functionality (for--disable-gilbuilds) #111964)2864b6b36egc: implement stop-the-world GC (Make the garbage collector thread-safe in--disable-gilbuilds #112529)c1befd7689Stop the world before fork() and Python shutdown (Use stop-the-world to make fork and interpreter shutdown thread-safe #116522)82800d8ec8ceval: stop the world when enabling profiling/tracing for all threads (Makesys.settrace,sys.setprofile, andsys.monitoringthread safe in--disable-gilbuilds #116818)7423dff344pystate: use stop-the-world in a few places (Use stop-the-world to makesys._current_frames()andsys._current_exceptions()thread-safe in free-threaded build #117300)86efa7dfe3pystate: implement _PyRuntime.multithreadedd896dfc8dbdict: make dict thread-safe (Makedictobjects thread-safe in--disable-gilbuilds #112075)df4c51f82blist: make list thread-safe (Makelistobjects thread-safe in--disable-gilbuilds #112087)9c1f7ba1b4mro: thread-safe MRO cache (Make the MRO cache thread-safe in free-threaded builds #113743)7a7aca096bgetargs.c: make parser_init thread-safe (Thread-safe one-time initialization #111956)0dddcb6f9dweakref: make weakrefs thread-safe without the GIL (Make weakref thread-safe without the GIL #111926)410ba1036adtoa: make dtoa thread-safe (dtoa: thread safety in--disable-gilbuilds #111962)6540bf3e6aunicode: make unicodeobject.c thread-safe (unicode: make_PyUnicode_FromIdthread-safe in--disable-gilbuilds #111971)5d006db9facodecs.c: fix race condition (unicode: make ucnhash_capi initialization thread-safe in--disable-gilbuilds #111972)d1b5ed128e_threadmodule: make _thread.lock thread-safe (Make_threadmodule.cthread-safe in--disable-gilbuilds #114271)cfc11bcb1atypeobject: thread safetycfecf6f4ebthreading: remove _tstate_lock from threading.Thread (Make_threadmodule.cthread-safe in--disable-gilbuilds #114271)74df7785f5pyqueue: add internal queue data structure4450445f51pymem: add _PyMem_FreeQsbr (Add delayed reclamation mechanism for free-threaded build (QSBR) #115103)7e60a01aeequeue: make SimpleQueue thread-safe (Make queue.SimpleQueue thread-safe in--disable-gilbuilds #113884)4ca2924f0dset: make set thread-safe (Makesetthread-safe in--disable-gilbuilds #112069)3cfbc49229moduleobject: fix data races5722416ef5_threadmodule: thread-safety fixes (Make_threadmodule.cthread-safe in--disable-gilbuilds #114271)31ec6f0290pystate: refcount threads to handle race between interpreter shutdown and thread exit45bdd27ee5threading: make _thread.lock thread-safe07f5f8c318slice: move slice_cache to per-thread state (Use per-thread freelists in--disable-gilbuilds #111968)ea1160c6d7asyncio: fix race conditions in enter_task and leave_task212fef480eobject.c: fix race when accessing attributes and methods (Use PyDict_GetItemRef() #111789)70856f126dasdl: use _PyOnceFlag in Python-ast.c (Thread-safe one-time initialization #111956)360a79cb88socketmodule.c: use relaxed atomics for global 'defaulttimeout' (socketmodule.c: use atomics to accessdefaulttimeoutin free-threaded build #116616)041a08e339functools: make lru_cache thread-safe (Makefunctools.lru_cachethread-safe in--disable-gilbuilds #112070)9bf62ffc4brandom: add a mutex to guard random.Random (Makerandom.Randomthread-safe in--disable-gilbuilds #112071)a8251a8d25clinic: support '@' syntax for recursive mutexes (Argument Clinic: Add support for PEP 703's critical sections (Py_BEGIN_CRITICAL_SECTION()) #111903)ffade9d6f6bufferedio: add locks to make print() thread-safe (Use critical sections to protect I/O objects (in--disable-gilbuilds) #111965)5b83c16dcdtextio: add locks to make textio thread-safe (Use critical sections to protect I/O objects (in--disable-gilbuilds) #111965)6323ca60f9stringio: make stringio thread-safe (Use critical sections to protect I/O objects (in--disable-gilbuilds) #111965)f1e4742eaadeque: make most functions thread-safe (Make collections.deque thread-safe in--disable-gilbuilds #112050)78825e0508importlib: fix data race in imports (PyImport_ImportModuleLevelObject)2f5c90a284semaphore.c: decrease count before release sem_lock (Make multiprocessingSemLockthread-safe in the free-threaded build #117435)22eca6e215sha1: make sha1module thread-safe (Make hashlib related modules thread-safe without the GIL #111916)ada9b73feb_struct: fix race condition in cache_struct_converter (Make_structmodule thread-safe in--disable-gilbuilds #112062)0e0b3899d1signalmodule: fix thread-safety issue on macOS (Unclear if this is still an issue on macOS)964bb33962json: make JSON scanner thread safe (json: make "memo" dict local to scan_once call #111928)86e7772c64http: fix dependency on finalization order9ab96964e7faulthandler: don't dump all threads when running without the GILcff32694a4test_gdb: skip test_threads when running without GIL2ae5ee5ed4tests: fix and work around some race conditions in tests9f9b3d085fceval: fix some thread-safety issues2a4c17e896pystate: move freelists to per-thread state (Use per-thread freelists in--disable-gilbuilds #111968)149ea9dc43Deferred reference counting7e7568672dspecialize: make specialization thread-safe90d34f0d18specialize: optimize for single-threaded programs42d3e11d8ccode: make code object use deferred reference countingc9fc49666ctest: add support for checking for TSAN7507a77a98thread: don't use sem_clockwait with TSANa62d37674c_posixsubprocess: disable vfork when running with ASAN398204d57bobject: fix reported TSAN races4526c07caeDisable the GIL by default in--disable-gilbuilds (Disable the GIL by default in free-threaded builds #116329)The text was updated successfully, but these errors were encountered: