Python features by version
Tags: python, features
Published: 2020-08-24 19:10:14

<!-- https://python.plainenglish.io/killer-features-by-python-version-c84ca12dba8 -->

From time to time I need to poke someone to use a new version of Python but I couldn't find the list of main features one gets by this. There is https://docs.python.org/3.10/whatsnew/index.html but that is too much info. So here is my concise list. Also, there is an [EOL (End of Life) date for every version](https://en.wikipedia.org/wiki/History_of_Python#Table_of_versions) in the brackets. More visual EOF site at https://devguide.python.org/versions/

### Python 3.12 (2028-10)
- New [Type Parameter Syntax](https://docs.python.org/3.12/whatsnew/3.12.html#pep-695-type-parameter-syntax) for generics in functions `def max[T](args: Iterable[T]) -> T:` classes `class list[T]:` and types `type Point[T] = tuple[T, T]`
- [Nested f-strings](https://docs.python.org/3.12/whatsnew/3.12.html#pep-701-syntactic-formalization-of-f-strings) `f"{f"{f"{f"{f"{f"{42-36}"}"}"}"}"}"`
- [A per-interpreter GIL](https://docs.python.org/3.12/whatsnew/3.12.html#pep-684-a-per-interpreter-gil)

### Python 3.11 (2027-10)
- between 10-60% speedup
- [Fine-grained error locations in tracebacks](https://docs.python.org/3.11/whatsnew/3.11.html#pep-657-fine-grained-error-locations-in-tracebacks)
- [Enhanced error locations in tracebacks](https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks)
- Support for parsing TOML files in the Standard Library

### Python 3.10 (2026-10)
- [Pattern matching](https://docs.python.org/3.10/whatsnew/3.10.html#pep-634-structural-pattern-matching)
```python
    match point:
        case Point(x=0, y=0):
            print("Origin is the point's location.")
        case Point(x=0, y=y):
            print(f"Y={y} and the point is on the y-axis.")
        case Point(x=x, y=0):
            print(f"X={x} and the point is on the x-axis.")
        case Point():
            print("The point is located somewhere else on the plane.")
        case _:
            print("Not a point")
```
- [Type alias](https://docs.python.org/3.10/whatsnew/3.10.html#pep-613-typealias-annotation) `StrCache: typing.TypeAlias = "Cache[str]"`
- [Union type operator](https://docs.python.org/3.10/whatsnew/3.10.html#pep604-new-type-union-operator) `def square(number: int | float) -> int | float:`
- [Better error messages](https://docs.python.org/3.10/whatsnew/3.10.html#better-error-messages-in-the-parser) with precise line numbers for debugging and other tools
- [Parenthesized context managers](https://docs.python.org/3.10/whatsnew/3.10.html#parenthesized-context-managers)
```python
with (
    CtxManager1(),
    CtxManager2()
):
    ...
```

### Python 3.9 (2025-10)
- [Dictionary merge](https://docs.python.org/3.10/whatsnew/3.9.html#dictionary-merge-update-operators) `assert {"a": 1} | {"b": 2} == {"a": 1, "b": 2}`
- [New string methods](https://docs.python.org/3.10/whatsnew/3.9.html#pep-616-new-removeprefix-and-removesuffix-string-methods)`str.removeprefix(prefix)` and `str.removesuffix(suffix)`
- [Builtin Generics](https://docs.python.org/3.10/whatsnew/3.9.html#pep-585-builtin-generic-types) `list[dict[str, int]]` vs. `typing.List[typing.Dict[str, int]]`
- [New PEG parser](https://docs.python.org/3.10/whatsnew/3.9.html#pep-617-new-parser)
- [New module `zoneinfo`](https://docs.python.org/3.10/whatsnew/3.9.html#zoneinfo) for timezones information

### Python 3.8 (2024-10)
- [The walrus operator](https://docs.python.org/3.10/whatsnew/3.8.html#assignment-expressions) `if (n := len(a)) > 10: print(f"List is too long ({n} elements, expected <= 10)")`
- [Positional-only parameters](https://docs.python.org/3.10/whatsnew/3.8.html#positional-only-parameters) `len(obj, /)` which prevents awkward calls such as `len(obj="Hello")`
- [Self documenting f-strings](https://docs.python.org/3.10/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging) `f"{user=} {member_since=}" # "user='eric_idle' member_since=datetime.date(1975, 7, 31)"`
- [`cached_property`](https://docs.python.org/3.10/whatsnew/3.8.html#functools) is finally in the standard library

### Python 3.7 († 2023-06)
- [contextvars](https://docs.python.org/3.10/whatsnew/3.7.html#contextvars)
- [dataclasses](https://docs.python.org/3.10/whatsnew/3.7.html#dataclasses)
```python
@dataclass
class Point:
    x: float
    y: float
    z: float = 0.0

p = Point(1.5, 2.5)
print(p)   # produces "Point(x=1.5, y=2.5, z=0.0)"
```
- [Built-in breakpoint](https://docs.python.org/3.10/whatsnew/3.7.html#pep-553-built-in-breakpoint) function

### Python 3.6 († 2021-12)
- [f-strings](https://docs.python.org/3.10/whatsnew/3.6.html#pep-498-formatted-string-literals) `f'Hello {name}'`
- [undescores in number literals](https://docs.python.org/3.10/whatsnew/3.6.html#pep-515-underscores-in-numeric-literals) `10_000_000`
- [variable annotations](https://docs.python.org/3.10/whatsnew/3.6.html#pep-526-syntax-for-variable-annotations) `variable: Type = 29`
- [asynchronous generators and comprehensions](https://docs.python.org/3.10/whatsnew/3.6.html#pep-525-asynchronous-generators)
```python
async def ticker(delay, to):
    """Yield numbers from 0 to *to* every *delay* seconds."""
    for i in range(to):
        yield i
        await asyncio.sleep(delay)
```

```python
result = [i async for i in aiter() if i % 2]
result = [await fun() for fun in funcs if await condition()]
```
- New [module "secrets"](https://docs.python.org/3.10/whatsnew/3.6.html#secrets)
- Type `dict` is [more compact and ordered by default](https://docs.python.org/3.10/whatsnew/3.6.html#new-dict-implementation)

### Python 3.5 († 2020-09-30)
- [`async/await` syntax](https://docs.python.org/3.10/whatsnew/3.5.html#pep-492-coroutines-with-async-and-await-syntax)
- [matrix multiplication operator](https://docs.python.org/3.10/whatsnew/3.5.html#pep-465-a-dedicated-infix-operator-for-matrix-multiplication) `M @ N`
- [Additional Unpacking Generalizations](https://docs.python.org/3.10/whatsnew/3.5.html#pep-448-additional-unpacking-generalizations) `print(*[1], *[2], 3, *[4, 5])` and `function(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4})`
- [New enum for HTTP statuses](https://docs.python.org/3.10/library/http.html#http.HTTPStatus) `http.HTTPStatus.OK`
- [Type hints](https://docs.python.org/3.10/whatsnew/3.5.html#whatsnew-pep-484) `typing.Dict[str, typing.Any]`

### Python 3.4 († 2019-03-18)
- [built-in pip](https://docs.python.org/3.10/whatsnew/3.4.html#pep-453-explicit-bootstrapping-of-pip-in-python-installations)
- [New module `asyncio`](https://docs.python.org/3.10/whatsnew/3.4.html#asyncio)
- [Support for enums](https://docs.python.org/3.10/whatsnew/3.4.html#enum)
- [New module `pathlib`](https://docs.python.org/3.10/whatsnew/3.4.html#pathlib)
- [New module `statistics`](https://docs.python.org/3.10/library/statistics.html#module-statistics)

### Python 3.3 († 2017-09-29)
- [Built-in virtualenv](https://docs.python.org/3.10/whatsnew/3.3.html#pep-405-virtual-environments)
- [Generator delegation](https://docs.python.org/3.10/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator) `yield from another_generator()`
- [Exception context suppresion](https://docs.python.org/3.10/whatsnew/3.3.html#pep-409-suppressing-exception-context) `raise Exception("Ooops") from None`
- [Explicit unicode literals](https://docs.python.org/3.10/whatsnew/3.3.html#pep-414-explicit-unicode-literals) are back to make migration from Python 2 easier `u"I am unicode in both Python 2 and 3"`
- [New module `unittest.mock`](https://docs.python.org/3.10/library/unittest.mock.html#module-unittest.mock)
- [New module `ipaddress`](https://docs.python.org/3.10/library/ipaddress.html#module-ipaddress)

### Python 3.2 († 2016-02-20)
- [¯\_(ツ)_/¯](https://docs.python.org/3.10/whatsnew/3.2.html)

### Python 3.1 († 2012-04-09)
- [`OrderedDict`](https://docs.python.org/3.10/whatsnew/3.1.html#pep-372-ordered-dictionaries)
- `with` handles multiple context managers in single statement

### Python 3.0 († 2009-06-27)
- [Big pile of incompatibility](https://docs.python.org/3.10/whatsnew/3.0.html)