1 / 6

What’s New In Python 3.11 & Python 3.11.3?

Python 3.11 is finally here! Say hello to improved performance and faster startup times with Python 3.11. Your code will run smoother than ever before! et ready for new syntax features, and enhanced security.

inextures
Download Presentation

What’s New In Python 3.11 & Python 3.11.3?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What’s New In Python 3.11 & Python 3.11.3 ? The Python 3.11 changelog is a seemingly unending collection of bug fixes, improvements, and additions, the majority of which you may never discover. However, a few crucial new features may significantly improve your Python process when the stable release arrives. Here’s a rundown of the most significant new features in Python 3.11 and what they mean for Python developers. 1. Increased Speed The first big change that will thrill data scientists is an increase in speed—the usual benchmark suite now runs around 25% faster than in 3.10. According to the Python documentation, 3.11 can be up to 60% faster in some cases. 2. More Informative Error Tracebacks Another immediately useful feature in Python 3.11 is more detailed error messages. Python 3.10 already had better error reporting, thanks to the new parser used in the interpreter. Now, Python 3.11 expands on that by improving error message that pinpoints the specific location of the fault. Rather than returning a 100-line traceback that ends with a difficult-to-understand error message, Python 3.11 points to the expression that produced the error.

  2. In the preceding example, the Python interpreter refers to the x that caused the script to fail due to its None value. Because there are two objects with the ‘x’ attribute, the error would have been unclear in current Python versions. However, 3.11’s error handling clearly identifies the faulty expression. This example shows how 3.11 can identify an issue in a deeply nested dictionary and clearly identify the key the error belongs to. 3. Exception Notes “Explicit is better than implicit.” The preceding text is the second line of the Zen of Python, which is a list of Python’s 20 design principles. This is an example of the rule that Python code should be as expressive as feasible. Python 3.11 includes exception notes to emphasise this design approach. (PEP 678). When you raise an error, you may now call the add_note() function inside your unless clauses and give a custom message.

  3. If you have written a custom exception class like below, you can add multiple notes to the class inside the protected class-level attribute __notes__: 4. Exception Improvements •Multiple exceptions can be raised and handled at once with the new except* syntax and the new ExceptionGroup exception type. This allows the elegant handling of issues where multiple errors can be raised together, such as when dealing with asynchronous or concurrent methods or when dealing with multiple failures when retrying an operation. •“Zero-cost” exceptions: Exceptions now have no cost to a program unless they are actually raised. This means the default path for a try/except block is faster and uses less memory.

  4. •The time needed to catch an exception has been reduced by around 10%. •Exceptions can be enriched with contextual notes, separate from the text of the exception itself. 5. New Typing Function: Self Statically typed languages aid in the readability and debuggability of your code. Defining the exact kind of variables, function inputs, and outputs can save you hours of debugging effort and help others read your code more easily. Adding typing annotations will also allow modern IDEs to display function definitions as you enter their names, making your functions easier for others to understand. Until now, Python’s strong typing module provided classes for almost any data type, except for classes that return instances of themselves. However, Python 3.11 provides the Self class, which you can include in the declaration of a function if the function’s return value is self or a new instance of the class itself.

  5. 6. Upgrades to the Standard Libraries There are a few other quality-of-life improvements to the standard libraries. First, two long-awaited functions are added to the math module. It’s remarkable that it took Python 28 years to include the cube-root function, but as the phrase goes, better late than never. A new feature in the fractions module allows you to build fractions from strings: As you can see, the fractions module is useful for some arithmetic operations. I particularly enjoy how you can get the fraction that is closest to the supplied float. You can go one step farther by specifying a denominator limit: There is also a new tomllib module for parsing TOML documents. Tom’s Obvious Minimal Language (TOML) is a common file format for creating human-readable configuration files. Python uses TOML, or Tom’s Obvious Minimal Language, as a configuration format (as in pyproject.toml), but doesn’t expose the ability to read TOML-format files as a standard library module. Python 3.11 adds tomllib to address that problem. 8. Conclusion A new release of Python is always cause for celebration, and acknowledgment of all the effort that’s been poured into the language by volunteers from around the world. In this blog, you’ve seen new features and improvements like: oBetter error messages with more informative tracebacks oFaster code execution due to considerable effort in the Faster CPython project oTask and exception groups that simplify working with asynchronous code •Several new typing features that improve Python’s static typing support •Native TOML support for working with configuration files Originally published by: What’s New In Python 3.11 & Python 3.11.3 ?

More Related