The latest version of the programming language Python, 3.11 has been unveiled, with its development team claiming that the new edition might just be the best yet.
In the release notes (opens in new tab), Pablo Galindo Salgado, Python Steering Council member and the release manager for the current version, alongside fellow team members Steve Dower and Ned Deily, wrote the team has “put a lot of effort into making 3.11 the best version of Python possible”.
They also listed the keynote improvements in Python 3.11: “better tracebacks”, “faster Python”, “exception groups and except*”, in addition to offering various improvements to typing.
Python 3.11’s latest improvements
The Python release team claimed in the release notes that Python 3.11 “is up to 10-60 percent faster than Python 3.10”, and reported measuring 1.22x speedups on average, courtesy of the Faster CPython Project (opens in new tab).
Though it is worth pointing out this likely only applies to pure Python code, and Python itself has never been the fastest programming language out there, that’s still impressive.
Several Python Enhancement Proposals (PEPs) promise to offer more concrete quality of life improvements.
PEP 657 (opens in new tab), for example, will introduce more detailed error reports for tracebacks – reports detailing function calls within a python script, making debugging that much more straightforward. PEP 680 (opens in new tab), meanwhile, means that Python will be able to parse TOML files, commonly used for configuration files without the need for an external library.
However, as The Register (opens in new tab) reports, PYC files compiled by the Python interpreter are now, on average, 22% larger, and while the Python team stand by the change, they have issued an opt-out, in the form of “PYTHONNODEBUGRANGES”, a new environmental variable.
PEP 654 (opens in new tab), on the other hand, allows for handling several exceptions at once with the introduction of exception groups and the new except* syntax.
Python 3.11 should also encourage developers to use data types more, thanks to some new features, and more subtle changes that give developers more control in the backend.
Perhaps the best illustration of this is PEP 675 (opens in new tab), which allows users to declare arbitrary string types, but there’s also PEP 673 (opens in new tab) (the Self Type), an intuitive way to annotate methods that return instances of the same class. Finally, PEP 646 (opens in new tab) (Variadic Generics), allowing generics to store several types at once for assignment to objects later.