The Pyrona project is an attempt to take ideas from the Verona project and apply them to Python. It started when someone made the observation that Python was trying to get to “the place that Java is trying to get away from”, referencing Python’s move towards “free-threading” and Java’s introduction of virtual threads and likening the latter to the lightweight concurrency behaviours in the Verona project, asking: “what would it look like if Python tried to skip directly to where the Verona folks are at?”.
The three main Verona components that Pyrona is building on are immutability, region-based ownership, and behaviour-oriented concurrency. These are mirrored in the following Python-oriented research papers and artefacts:
Immutability is an important programming language concept. Making data immutable can help prevent bugs and make code easier to reason about. In the context of concurrent or parallel programming, immutability provides a way to safely share data across threads or processes.
The most common way to achieve immutability in programming languages is through static checking – for example, in C and C++, declaring a variable as const prevents it from being modified, and conformance is checked at compile-time. Python does not have built-in support for immutable types, and its type system is too weak to readily support immutability.
In its simplest form, making an object immutable uses a single bit in the object’s header to mark it as immutable; in the interpreter, all modifications to the object must inspect the immutability bit flag and raise an exception if it is set. This implements shallow immutability – an object whose bit is set cannot be modified, but any sub-objects it contains can still be modified. Since the internal details of how an object is constructed can be hidden from its clients, a shallow immutable object can appear as if it is still mutable.
In contrast to shallow immutability, deep immutability requires that all sub-objects of an immutable object are also immutable. This is more strict than shallow immutability, and provides stronger guarantees about the object’s state.
p1 = Person("Alice", 30)
p2 = Person("Bob", 25)
team = [p1, p2]
freeze(team)
is_frozen(team) # True
is_frozen(p1) # True
is_frozen(Person) # True
Our proposal for adding deep immutability to Python is to use a function freeze(obj) that recursively freezes obj and all its sub-objects. This may seem trivial at first, but as explained in our PLDI 2026 paper, there are several obstacles that must be overcome. In particular, objects in Python are deeply interconnected, and it is often common to find a path between any two objects via their attributes or methods. This means that freezing a single object may have far-reaching consequences, as it may freeze a large number of objects that are not directly related to the original object, and may even cripple the interpreter. For example, an object has a reference to its type and the type has references to function objects that implement the methods; the function objects reference the global namespace, so freezing the object ends up freezing the global namespace as well.
Our solution to this problem is detachment – we disconnect objects from their normal Python object graph in order to stop freezing from propagating. For example, when freezing a function object, we detach it from the global namespace so that freezing it does not affect the global namespace. This is transparent to the function itself, except that changes to the global namespace are not visible to the function, which is the desired behaviour for immutability.
Python’s memory management is based on reference counting plus a separate cycle detection algorithm to prevent cyclic references from causing memory leaks. An interesting realisation in our work is that cyclic immutable garbage can be handled correctly using only reference counting: because objects in an immutable cycle will have exactly the same lifetime, a single reference count can be used to track all the objects in the cycle. When an object graph is frozen, we perform a strongly connected component analysis to detect all cycles and change how they are reference counted so that reference count increments and decrements on objects in the cycle all operate on the same shared counter.
We gave a presentation at EuroPython 2026 about our work on deep immutability. The talk is available here. Additional details are available in our PLDI 2026 paper, and a recording of the talk for this paper is available here. Finally, if you want to play around with our implementation, the paper has a convenient artefact. You can also build it from source.
Region-based ownership is a technique for partitioning a program’s memory into regions, where each region is owned by a single object. When a region is closed, the objects inside the region are not reachable from outside the region which means that it is safe to transfer the region from one thread to another. When a thread receives a closed region, it thus knows that the sender has no more references to the objects inside the region and that it can access them safely without any race conditions.
Although a region is not a lock, a region can be likened with a lock that knows what data it owns, and that raises an exception if data is accessed without holding the lock, or if the lock is released while references to its owned objects are still held.
Our proposal for region-based ownership in Python is documented in a PLDI’25 paper. It builds on our OOPSLA’23 paper on reference capabilities for flexible memory management and is part of the Verona design. Similar to immutability, ownership systems typically build on static type systems to enforce ownership rules at compile time. Just like with immutability, our proposal builds on runtime checking to enforce ownership rules. This is necessary for soundness – because Python’s type system can be circumvented, it cannot provide strong guarantees about ownership (or immutability).
In Lungfish, as our proposal is called, regions are reified by a single region object created thus: r = Region(). If r.f = obj, then obj is moved into r.
Objects inside a region may only reference:
A program that breaks these rules will raise an exception. When this exception is raised depends on how the region system is implemented. Our PLDI’25 paper describes a write-barrier based technique for dynamic checking which will raise an exception immediately when the rules above are violated. An alternative implementation based on tracing will raise the exception when the region is closed. There are pros and cons to each approach.
The rules for what objects inside a region can reference pose a problem for Python due to its reification of classes and methods as first-class objects. Since the class Person is an object, two instances of Person, p1 and p2 say, will both reference the same class object, but if p1 and p2 are in different regions, this will break the region-based ownership rules.
The solution is to make classes and methods immutable, so that two instances of the same class can reside in different regions without violating the region-based ownership rules. In our Lungfish proposal, we freeze objects automatically when they become shared between regions.
We gave a presentation at the Python Language Summit in 2025 about these ideas. The presentation slides are available here. Additional details are available in our PLDI 2025 paper, and a recording of the talk for this paper is available here. A trace-based implementation of regions is available here.
Behaviour-oriented concurrency is a generalisation of the actor paradigm. In the actor model, actors bundle state and behaviour together, and each actor runs a single thread of control. In behaviour-oriented concurrency, behaviour and state are decoupled, and each behaviour runs in its own thread of control on zero or more units of state. The result is a more flexible and scalable concurrency model where a programmer has control over scheduling and can reason about causality.
The hello world example of behaviour-oriented concurrency is atomic transfer of funds between two accounts. The JavaScript-like code below reads “when I have exclusive access to both accounts, transfer the funds from one to the other.”
when (src, dst) => {
src.balance -= amount
dst.balance += amount
}
Technically, the code above sends the lambda function to the scheduler, which will execute it when the appropriate resources are available. The scheduler ensures that no two lambda functions will run concurrently on the same resource. The runtime ensures that concurrent when’s over multiple resources do not cause deadlock.
In behaviour-oriented concurrency, behaviours operate on cowns (pronounced “cones”) which is short for “concurrent owner”. A concurrent owner is a cell that holds a single region object. When a region is closed, it only has a single incoming reference from outside the region to its region object. Thus, a cown that holds a closed region owns the region and its contents. To read the contents of a cown, the cown must be acquired which requires the use of a when. Consider the code example above: both src and dst are cowns that hold closed regions, and the lambda that operates on their contents will only be executed by the scheduler when both src and dst have been acquired. Once the lambda function finishes, all temporary references to the regions have been invalidated; the scheduler releases the cowns which closes the regions. If the program had created illegal references into the regions, this would be detected when the regions are closed and raised an exception. In our Python implementation, behaviours are implemented using decorators. Here is how to express the transfer behaviour:
@when(src, dst)
def _(src, dst):
src.value.balance -= amount
dst.value.balance += amount
Because amount is an immutable value, it is safe to share across behaviours.
Writing behaviour-oriented code is different from writing with threads and locks. A when does not block – it simply registers a behaviour to be executed when the scheduler has the required resources available at the same time. It is common for a behaviour to end by spawning a new behaviour over some possibly overlapping resources to take the next step in the process. This requires thinking differently about programs than with threads and locks.
As described in detail in Luke Cheeseman’s PhD thesis, behaviours guarantee certain schedules over resources. Consider the following example:
@when(a)
def _(a):
pass # Behaviour A
@when(a, b)
def _(a, b):
pass # Behaviour B
@when(a)
def _(a):
pass # Behaviour C
@when(b)
def _(b):
pass # Behaviour D
Because behaviour A is spawned before behaviour B which also requires the a cown, A will always be executed first. The same reasoning applies to B, C and D – because B is spawned before C and both require cown a, B will always be executed before C, and because B is spawned before D and both require cown b, B will always be executed before D. Note that C and D are not ordered with respect to each other and can be executed in any order or in parallel.
Now consider the following example:
@when(a)
def _(a):
# Behaviour A
@when(b)
def _(b):
pass # Behaviour B
@when(a)
def _(a):
# Behaviour C
@when(b)
def _(b):
pass # Behaviour D
Because behaviour A is spawned before behaviour C, A will always be executed before C, since they share the same cown a. Because behaviour B is spawned before behaviour D, B will always be executed before D, since they share the same cown b.
Even though Python does not yet support immutability or regions, the bocpy library – available on PyPI through pip install bocpy – provides a way to write behaviour-oriented concurrent programs in Python. Bocpy uses Python’s multiple subinterpreters to execute behaviours in parallel without requiring a free-threaded build, which means that objects are pickled and unpickled across subinterpreters. As long as behaviours are sufficiently long-running or the object structures inside the cowns are not too complex, this approach can be effective for parallelising CPU-bound tasks, and outperform free-threaded Python in many cases.
The bocpy library has a rudimentary webpage here. Matthew Johnson gave a talk on bocpy at PyCon US 2025).
We have benefited immensely from discussions with Guido van Rossum, Brandt Bucher, Eric Snow, Mark Shannon, and Donghee Na. Brandt Bucher, Eric Snow, and Guido van Rossum are co-authors of the PLDI’25 paper on region-based ownership.
Left to right: Matthew J, Matthew P, Sylvan, Tobias, Fridtjof
Below we list the thesis projects in Pyrona for each year. There are some suggested thesis proposals here, but feel free to propose your own.