You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -4,7 +4,7 @@ Author: Mark Shannon <mark@hotpy.org>
Discussions-To: Pending
Status: Draft
Type: Standards Track
Created: 08-Sep-2025
Python-Version: 3.15
Abstract
========
Expand All
@@ -23,11 +23,11 @@ Traditionally, CPython has executed in only a single thread of execution at once
This has always been seen as a limitation of Python and there has been a desire for
Python to support parallel execution for many years.
PEP 703, Making the Global Interpreter Lock Optional in CPython, and PEP 554, Multiple Interpreters in the Stdlib, offer ways to support parallelism.
:pep:`703`, Making the Global Interpreter Lock Optional in CPython, and :pep:`554`, Multiple Interpreters in the Stdlib, offer ways to support parallelism.
Multiple interpreters are both safe and support parallelism, but they are difficult to use and sharing objects
between multiple interpreters without copying is impossible.
PEP 703 supports parallel execution and sharing, but is unsafe as it allows race conditions.
Race conditions allow dangerous and hard to find bugs. In the most extreme example, Therac-25 [1]_, a race condition bug resulted in several fatalities. The trouble with race conditions is not that the bugs they introduce are necessarily worse than other bugs,
Race conditions allow dangerous and hard to find bugs. In the most extreme example, `Therac-25 <https://en.wikipedia.org/wiki/Therac-25>`__, a race condition bug resulted in several fatalities. The trouble with race conditions is not that the bugs they introduce are necessarily worse than other bugs,
but that they can be very hard to detect and may easily slip through testing.
Parallelism, without strong support from the language and runtime, is extremely difficult to get right:
Expand DownExpand Up
@@ -71,7 +71,7 @@ The PEP also proposes changes to CPython to prevent unsafe execution when mutabl
Finally, the PEP provides a generalization of the GIL to allow incrementally moving away from the GIL.
This PEP is inspired by ideas from OCaml, specifically Data Freedom à la Mode [2]_, and the Pyrona project [3]_.
It is the author's opinion that attempting to preserve single-threaded performance
for mutable objects *and* any sort of thread safe parallel execution for the same object is wishful thinking.
Expand All
@@ -475,7 +475,7 @@ Object state
Recording object state requires space in the object header, at least 3 bits but no more than a byte.
Each object also needs additional space to refer to its thread, or protecting mutex.
With these fields, the ``PyObject`` header should be the smaller than is currently implemented for PEP 703,
With these fields, the ``PyObject`` header should be the smaller than is currently implemented for :pep:`703`,
although larger than for the default (with GIL) build.
A possible object header:
Expand DownExpand Up
@@ -543,11 +543,11 @@ Possible future enhancements
Deep freezing and deep transfers
--------------------------------
Freezing a single object could leave a frozen object with references to mutable objects, and transfering of single objects could leave an object local to one thread, while other objects that it refers to are local to a different thread.
Freezing a single object could leave a frozen object with references to mutable objects, and transferring of single objects could leave an object local to one thread, while other objects that it refers to are local to a different thread.
Either of these scanarios are likely to lead to runtime errors. To avoid that problem we need "deep" freezing.
Deep freezing an object would freeze that object and the transitive closure of other mutable objects referred to by that object.
Deep transfering an object would transfer that object and the transitive closure of other local objects referred to by that object,
Deep transferring an object would transfer that object and the transitive closure of other local objects referred to by that object,
but would raise an exception if one of the those objects belonged to a different thread.
Similar to freezing, a "deep" put mechanism could be added to ``Channel``\ s to move a whole graph of objects from one thread
Expand All
@@ -565,17 +565,6 @@ Open Issues
[Any points that are still being decided/discussed.]
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.