---
title: "Python 3.8: walrus operator, positional-only, advanced typing"
description: "Python 3.8 (14 October 2019): walrus operator :=, positional-only / parameters, self-documenting f-strings, typing with TypedDict/Final/Literal/Protocol, performance improvements. The release consolidating Python in the modern type-hinting era."
url: "https://www.noze.it/en/insights/python-3-8-walrus/"
lang: "en"
alternate: "https://www.noze.it/insights/python-3-8-walrus/"
published: "2019-10-14"
author: "noze S.r.l."
keywords: "Open Source, Web, R&D, Python, Python 3.8, Walrus Operator, Typing, Łukasz Langa"
---

# Python 3.8: walrus operator, positional-only, advanced typing

Python 3.8 (14 October 2019): walrus operator :=, positional-only / parameters, self-documenting f-strings, typing with TypedDict/Final/Literal/Protocol, performance improvements. The release consolidating Python in the modern type-hinting era.

14 October 2019

## The language eleven years after 3.0

On **14 October 2019** the Python Software Foundation released **Python 3.8**, under **Łukasz Langa** as Release Manager. Eleven years after Python 3.0’s release (December 2008), the line is mature, stable, with a boundless library ecosystem. 3.8 consolidates several trajectories opened by earlier releases, with thoughtful new syntax additions.

3.8 is a **Regular Release** with a five-year support window under the standard support cycle. The transition from Python 2 — whose end-of-life is scheduled for 1 January 2020 — is being completed in most production projects.

## Walrus Operator (PEP 572)

The most debated syntactic novelty is the **walrus operator** `:=`, described by **PEP 572**. It allows **assignment and evaluation** in a single expression:

```
# Before
line = file.readline()
while line:
    process(line)
    line = file.readline()

# With walrus
while line := file.readline():
    process(line)
```

Or in filters and comprehensions:

```
filtered = [y for x in data if (y := compute(x)) > threshold]
```

The public discussion on PEP 572 was heated — **Guido van Rossum** (historic BDFL) expressed support and even declared the intensity of the debate led him to decide to **step down** from leading the language (announcement July 2018, transition to Steering Council governance). 3.8 is the first post-BDFL release and the first to formally include the new operator.

## Positional-only parameters (PEP 570)

PEP 570 introduces the `/` syntax to mark parameters as positional-only:

```
def greet(name, /, greeting="Hello"):
    return f"{greeting}, {name}!"

greet("Anna")                       # OK
greet("Anna", greeting="Hi")        # OK
greet(name="Anna")                  # TypeError: name is positional-only
```

This construct aligns Python with built-in functions (e.g. `len(obj, /)`) and allows safe refactors: renaming a parameter is not a breaking change if it is positional-only.

## Self-documenting f-string

Small but welcome: `f"{x=}"` produces `x=value`, useful for debugging:

```
x = 42
y = [1, 2, 3]
print(f"{x=}, {y=}")  # x=42, y=[1, 2, 3]
```

## Evolved typing

The `typing` module gains significant constructs:

### TypedDict (PEP 589)

Types dicts with known schema:

```
from typing import TypedDict

class User(TypedDict):
    name: str
    age: int
    active: bool

u: User = {"name": "Anna", "age": 30, "active": True}
```

### Final (PEP 591)

Marker for non-overridable variables/methods:

```
from typing import Final
MAX_RETRIES: Final = 5
```

### Literal (PEP 586)

Types accepting only specific values:

```
from typing import Literal
def log(level: Literal["debug", "info", "error"]) -> None: ...
```

### Protocol (PEP 544)

Structural subtyping — formalised “duck typing”:

```
from typing import Protocol

class Drawable(Protocol):
    def draw(self) -> None: ...

def render(obj: Drawable) -> None:
    obj.draw()
```

Python typing, started with PEP 484 in 2015, reaches in 3.8 a maturity that enables type checkers like **mypy**, **pyright** (Microsoft), **pyre** (Facebook), **pyre-check** to work on complex enterprise codebases.

## Performance

3.8 includes diffuse optimisations:

- **Shared cache for module metadata** — faster imports
- **Optimised LOAD_GLOBAL opcode**
- **asyncio run() and Task improvements**
- **pickle Protocol 5** (PEP 574) — out-of-band buffers, zero-copy for large data

## Other contributions

- **multiprocessing.shared_memory** (related to PEP 574) — cross-process shared memory without serialisation
- **reversed() for dict** — reverse-order iteration
- **Math constants** — `math.prod()`, `math.isqrt()`, `math.perm()`, `math.comb()`
- **sys.platform** for Android
- **f-string ’=’ specification**

## Breaking changes

3.8 introduces no massive breakage but:

- **Python 2 is fully deprecated** — EOL scheduled for 1 January 2020
- Some modules deprecated from 3.3/3.4 are removed
- **DeprecationWarning** visible by default in `__main__`

## Ecosystem impact

Main libraries update to leverage novelties:

- **Django** — walrus and positional-only support in internal methods
- **FastAPI** (growing from 2018) — deep integration with TypedDict/Protocol typing
- **Pydantic** — field validation with Literal
- **SQLAlchemy 2.x** (in development) — extensive use of TypedDict and Protocol
- **pytest**, **Flask**, **Celery** — progressive updates

## In the Italian context

Python 3.8 enters Italian projects at the usual pace:

- **Data science** — analytics teams adopt rapidly (pandas, NumPy, Jupyter ready)
- **Web** — Django and FastAPI in production
- **ML/AI** — TensorFlow, PyTorch compatible
- **PA** — new Python projects adopt 3.8; existing 3.6/3.7 projects progressively migrate

---

_References: Python 3.8.0 (14 October 2019). Łukasz Langa as Release Manager. PEP 572 (walrus), PEP 570 (positional-only), PEP 589 (TypedDict), PEP 591 (Final), PEP 586 (Literal), PEP 544 (Protocol), PEP 574 (pickle 5). Python Steering Council (post-BDFL, 2018). Python Software Foundation._
