Major Python syntax changes by version

This is going to be mainly my cheatsheet for different python syntax and standard library changes, because I often work with multiple Python versions across projects and I never remember which feature was released in which major Python version.

Also I'll only list only what I consider major for my use cases, a.k.a. the features I use the most. For the rest, I can always look it up.

3.13

Release announcement

  • We can disable GIL, but that requires python3-freethreading (on Fedora)
  • Experimental JIT
  • 🗑️ Removed lib2to3

3.12

Release announcement

  • More flexible f-string parsing (quotes inside f-strings, nested f-strings)
  • Improved error messages
  • @override decorator
  • Generic types: def func[T](it: Iterable[T]) -> T:
  • Easier alias type using type: type MyType = list[str]
  • 🗑️ Removed assertEquals and similar old style named methods in unittest
  • 🗑️ Removed distutils

3.11

Release announcement

  • Fine-grained error locations in tracebacks
  • Exception groups
  • Self type
  • Speed up 🚀
  • tomllib

3.10

Release announcement

  • Union types (X | Y)
  • match statement
  • TypeAlias

3.9

Release announcement

  • Union operator in dict (d1 |= d2)
  • str.removeprefix and str.removesuffix
  • Type hinting generics: list, dict, set instead of typing.List, etc...

3.8

Release announcement

  • Walrus operator (:=)
  • Positional only arguments (pow(x, y, /))
  • f-string = format for debugging
  • Literal types
  • TypedDict

3.7

Release announcement

  • breakpoint()
  • dataclasses

3.6

Release announcement

  • f-strings
  • dict keys stored in order of insertion (CPython)

3.5

Release announcement

  • Typing module