Kiratas
  • Home
  • World
  • Lifestyle

    Trending Tags

    • Pandemic
  • Business
  • Entertainment
  • Sports
No Result
View All Result
  • Home
  • World
  • Lifestyle

    Trending Tags

    • Pandemic
  • Business
  • Entertainment
  • Sports
No Result
View All Result
Kiratas
No Result
View All Result
Home World

Python 3.12 focuses on performance, clear syntax and more precise error messages

Keira Austin by Keira Austin
May 24, 2023
in World
0
Python 3.12 focuses on performance, clear syntax and more precise error messages
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Python 3.12 focuses on performance, clear syntax and more precise error messages

The Python Software Foundation has released the first beta of Python 3.12. In the fresh version, the programming language comes with some syntactical additions, including for generic classes, functions and type aliases as well as for F-strings. There are also adjustments aimed at better performance and improvements in error messages.

With the first beta, Python 3.12 is considered feature complete, so new functions are no longer to be expected. The release roadmap for Python 3.12 includes three more betas and two release candidates before the final release is scheduled for October 2nd.

Clear Syntax

Python has known formatted string literals or F-strings since version 3.6. They allow you to easily integrate expressions into strings and thus include variables directly, for example. However, the original Python Enhancement Proposal PEP 498 dispensed with formal syntactical specifications and has some limitations. For example, a string delimited with single quotes (‘) does not allow (‘) within the expressions. The PEP 701 included in Python 3.12 now formalizes the syntax for F-strings and thus expands the possible uses.

Python 3.12 also offers a new, clearer syntax for generic type aliases, functions and classes, which is based on other programming languages. The associated PEP 695 compares the old and new notation for generic classes:

# bisherige Schreibweise
from typing import Generic, TypeVar

_T_co = TypeVar("_T_co", covariant=True, bound=str)

class ClassA(Generic[_T_co]):
    def method1(self) -> _T_co:
        ...
        
# ab Python 3.12
class ClassA[T: str]:
    def method1(self) -> T:
        ...

performance and error messages

The additions intended to improve performance include PEP 709, which implements comprehensions, i.e. filtered copies of lists, dictionaries and sets, differently internally. Until now, Python has used nested functions for this. From version 3.12 it uses inlining instead. In the best case, the individual comprehensions should work twice as fast, and the proposal speaks of an 11 percent improvement in performance of a real application with many comprehensions.

Meaningful error messages were already the focus in version 3.11. At that time, PEP 657 ensured that the Python interpreter displayed the exact expression in which an error occurred in tracebacks. Previously, it had merely spat out the associated line number. In Python 3.12, error messages indicate, among other things, potentially missing module import statements as the cause of a NameError:

sys.version_info
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined. Did you forget to import 'sys'?

There are also indications that assignments may have been mixed up if the code says import foo from bar instead of from bar import foo.

Less GIL restriction

The Python community has been concerned with an innovation for a long time: a way out of the trap of the Global Interpreter Lock (GIL). It restricts concurrent programs because all Python interpreters are subject to the same global lock. PEP 684 allows to create sub-interpreters that have independent locks.

The related and five-year-old PEP 554 for multiple interpreters in the standard library via an interpreters module, on the other hand, is only marked for launch in the upcoming version 3.13.

Another noteworthy new feature in Python 3.12 is that the perf profiler on Linux now outputs the names of Python functions in traces. In addition, numerous features marked as deprecated are no longer available in the current release.

More details can be found in the blog post on the first beta. The full list of changes can be found in the changelog. (rm)

To home page

Tags: clearerrorfocusesmessagesperformancepreciseprogramming languagesPythonsyntax
Previous Post

The PP places a giant shopping cart to blame Sánchez for “the rise in prices”

Next Post

The Supreme Court confirms the sentences of 10 to 12 years for the ‘herd’ of Manresa for a crime of sexual abuse of a minor

Keira Austin

Keira Austin

Related Posts

The rate at which sea level rises in Spain has doubled: "It will have serious effects", warns the CSIC
World

The rate at which sea level rises in Spain has doubled: “It will have serious effects”, warns the CSIC

by Keira Austin
June 5, 2023
These are the best cans of tuna you can buy at the supermarket, according to the OCU
World

These are the best cans of tuna you can buy at the supermarket, according to the OCU

by Keira Austin
June 5, 2023
Carlos García warns Otegi: "EH Bildu is going to be kicked out of Durango by the PP of Jesús Mari Pedrosa and Miguel Ángel Blanco"
World

Carlos García warns Otegi: “EH Bildu is going to be kicked out of Durango by the PP of Jesús Mari Pedrosa and Miguel Ángel Blanco”

by Keira Austin
June 5, 2023
The tie dye midi skirt that women over 50 are not going to take off throughout the month of June has just arrived at Zara
World

The tie dye midi skirt that women over 50 are not going to take off throughout the month of June has just arrived at Zara

by Keira Austin
June 5, 2023
Ana Rosa Quintana goes all out in the 23J elections: "We are going to be here"
World

Ana Rosa Quintana goes all out in the 23J elections: “We are going to be here”

by Keira Austin
June 5, 2023
Next Post
The Supreme Court confirms the sentences of 10 to 12 years for the 'herd' of Manresa for a crime of sexual abuse of a minor

The Supreme Court confirms the sentences of 10 to 12 years for the 'herd' of Manresa for a crime of sexual abuse of a minor

Premium Content

The judge imputes the son of Negreira for the millionaire charges of FC Barcelona

The judge imputes the son of Negreira for the millionaire charges of FC Barcelona

June 2, 2023
The woman accused of not delivering her ex-husband in Barcelona on time is acquitted

The woman accused of not delivering her ex-husband in Barcelona on time is acquitted

May 30, 2023
Cinco Días

The manufacturer of engine components Antolin wants to grow in Morocco to sell to Europe

June 5, 2023

Browse by Category

  • Business
  • Sports
  • World

Browse by Tags

28M Apple arrested artificial Artificial intelligence attack Barcelona campaign ChatGPT China data day elections electoral European euros Feijóo Government health intelligence June League live Madrid Microsoft million people PSOE Real result Russia Security Spain Spanish Sánchez time today Ukraine Valencia Vinicius vote Vox vulnerabilities war years
Kiratas

Latest News from World, Health, Politics, Sports, Business, Education, Technology, Arts and Latin America, the Middle East, South Asia.

Categories

  • Business
  • Sports
  • World

Browse by Tag

28M Apple arrested artificial Artificial intelligence attack Barcelona campaign ChatGPT China data day elections electoral European euros Feijóo Government health intelligence June League live Madrid Microsoft million people PSOE Real result Russia Security Spain Spanish Sánchez time today Ukraine Valencia Vinicius vote Vox vulnerabilities war years

Recent Posts

  • The rate at which sea level rises in Spain has doubled: “It will have serious effects”, warns the CSIC
  • These are the best cans of tuna you can buy at the supermarket, according to the OCU
  • Carlos García warns Otegi: “EH Bildu is going to be kicked out of Durango by the PP of Jesús Mari Pedrosa and Miguel Ángel Blanco”
  • About us
  • Home
  • Privacy Policy
  • Terms and Conditions

© Kiratas 2023. All Rights Reserved.

No Result
View All Result
  • Home
  • World
  • Lifestyle
  • Business
  • Entertainment
  • Sports

© Kiratas 2023. All Rights Reserved.