Python 3.11 is up to 60% faster and brings clearer error messages – Tecnoblog

One of the most popular programming languages ​​of recent times has just gained a version with several important features. I speak of Python 3.11. Among its new attributes is a performance boost of up to 60%. Another is to display more objective error messages, which clearly point out the problematic expression.

Python (illustrative image: Pexels/Christina Morillo)
Python (illustrative image: Pexels/Christina Morillo)

The latest Tiobe index list places Python as the most popular programming language at the moment, ahead of C, Java, C++ and C#. Therefore, improving the experience of developers working with Python is, above all, a matter of commitment to the community.

via Twitter, Pablo Galindo Salgadoa member of the language council, made it clear that this commitment is taken seriously:

On the CPython release team, we put a lot of effort into making 3.11 the best possible version of Python. Improved traces, faster Python, expect* and exception groups, typing advances, and more.

Python up to 60% faster

Let’s start with the most relevant news. Relative to version 3.10, Python 3.11 is between 10% and 60% faster in working with certain instances. In others, there may be no noticeable performance gain. But generally speaking, the developer who works regularly with the language is to be expected to notice the difference.

Speaking specifically of CPython (the main implementation of the language), the average performance gain is 25% compared to the previous version. This result was achieved in pyperformance (benchmark tool) with CPython 3.11 compiled via GCC on Ubuntu Linux.

There are several factors that contribute to this. For example, function calls now require less memory. Also, the Python interpreter now boots faster — somewhere between 10% and 15% faster than version 3.10.

Clearer error messages

Error messages are displayed to alert you that something is obviously wrong. But, not infrequently, the developer has to spend neurons to find out where, exactly, the fault is.

Perhaps this problem still exists in Python 3.11 in some form, but on a much smaller scale. That’s because the new version brings error messages designed to pinpoint the location of the error precisely.

On Twitter, the developer Ned Batchelder shows how it makes a difference. Notice that, in the second code of the example given by him, in Python 3.11, the characters ~ and ^ are used to indicate which expression is the fault. In the first, in Python 3.10, the error message is not accompanied by this indication:

Error messages in Python 3.10 and 3.11 (image: Twitter/Ned Batchelder)
Error messages in Python 3.10 and 3.11 (image: Twitter/Ned Batchelder)

Here’s another simple example, this one taken from the Python 3.11 news page:

Traceback (most recent call last):
  File "", line 54, in <module>
    result = (x / y / z) * (a / b / c)
ZeroDivisionError: division by zero

other news

Performance gains and more straightforward error messages are the main attributes of Python 3.11, but not the only ones. Among the others are:

  • handling of exception groups through the new except* syntax and the new ExceptionGroup exception type;
  • inclusion of the tomllib module so that the language can read or analyze files in TOML (Tom’s Obvious Minimal Language) format;
  • removal of “dead batteries”, ie obsolete modules from the Python standard library;
  • CPython now has native support for WebAssembly, albeit experimental.

All details can be found in the official Python 3.11 What’s New List. The address for downloading the language is this.

Source link

About Admin

Check Also

New Pix rules come into effect next month

The Central Bank of Brazil released a statement this Thursday (12/01), informing that some changes …

Leave a Reply

Your email address will not be published. Required fields are marked *