In the next September, a new Python version will be released to the world. I've selected a few key changes that are worth elaborating on and getting to know.
1. Better Interactive Interpreter
Python will be using a new interactive shell which means that when we use Python from the terminal we will get a new:
2. Improved Error Messages
From 3.13, the error messages will be colorized alongside the traceback, but what is most valuable in my eyes is that when the wrong keyword argument is passed to the function, the error message will suggest a proper one.
3. Support for Marking Deprecations
Decorator @deprecated
will be released. From this point, you will be able to mark function, class, or overload as deprecated and the message will be displayed during runtime and by the static types checkers.
4. Typing Improvements
TypeIs()
→ used for the situations where the function will return the type of the argument that is being passed to the function
def is_str(val: str) -> TypeIs[str]:
return isinstance(val, str)
ReadOnly()
→ special typing construct to mark variables of TypedDict as read-only. For example
class Movie(TypedDict):
title: ReadOnly[str]
year: int
def mutate_movie(m: Movie) -> None:
m["year"] = 1992 # allowed
m["title"] = "The Matrix" # typechecker error
5. Other Changes
There are quite a lot of things changing regarding how Python code works underneath, for example, changes regarding JIT compiler, incremental garbage collection, and support for mobile platforms, but I will not describe them since they are not interfering with the direct usage of it for most developers.
For more, feel free to visit official Python documentation page: https://docs.python.org/3.13/whatsnew/