PEP 484 introduced optional type annotations specifying expected types, supported by the `typing` module which provides generics like `List`, `Dict`, `Optional`, `Union`, and `Callable`. Static type checkers like mypy catch type errors before runtime. More advanced constructs include type aliases such as `UserID = int`, `TypeVar` for generic functions, `Generic` classes parameterized by type variables, `Optional[X]` (equivalent to `Union[X, None]`), `Literal` types (PEP 586) restricting values to specific literals, `TypedDict` (PEP 589) for dicts with fixed string keys and known value types, and `typing.Final` for names that cannot be reassigned.
String formatting has evolved through three eras: the oldest uses `%` formatting like `"%s %d" % (a, b)`, followed by `str.format()` with `"{} {}".format(a, b)`, and finally f-strings (PEP 498) such as `f"value={x}"`. F-strings also support a debug mode where `f"{x=}"` produces output like `x=value`. PEP 572 introduced the walrus operator `:=`, which assigns within an expression and is particularly useful inside comprehensions for reusing a computed value. Python 3.10 added structural pattern matching via `match`/`case` (PEP 634), where the `match` clause uses pattern syntax rather than equality comparison.
Recent Python versions keep expanding capabilities. Python 3.11 added exception groups for raising multiple unrelated exceptions together, task groups for structured concurrency in asyncio, and `tomllib` for reading TOML files. `asyncio.timeout()` raises a timeout error after a specified duration. PEP 684 in Python 3.12+ introduced per-interpreter GIL, enabling true parallelism between sub-interpreters. PEP 657 improved tracebacks to point at specific expressions rather than just lines, making debugging faster.