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. The individual comprehensions should ideally 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

Villacís assures that he will take advantage of the Vice Mayor's office "until the last moment"
World

Villacís assures that he will take advantage of the Vice Mayor’s office “until the last moment”

by Keira Austin
June 5, 2023
They locate the lifeless woman who disappeared on Friday in Mallorca
World

They locate the lifeless woman who disappeared on Friday in Mallorca

by Keira Austin
June 5, 2023
Fagerström, expert against smoking: "We can free the world from cigarettes, but not from nicotine"
World

Fagerström, expert against smoking: “We can free the world from cigarettes, but not from nicotine”

by Keira Austin
June 5, 2023
EL PAÍS
World

The Civil Guard warns of the increase in apparently intentional fires in plastic recycling plants

by Keira Austin
June 5, 2023
Carmen Borrego's son breaks his silence after the birth of his baby
World

Carmen Borrego’s son breaks his silence after the birth of his baby

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

EL PAÍS

The left in Alcorcón maintains the Mayor’s Office despite the appeal of the PP

June 3, 2023
Ayuso, absolute majority and PSOE and Más Madrid equalized as the second force in the Community of Madrid

Ayuso, absolute majority and PSOE and Más Madrid equalized as the second force in the Community of Madrid

May 28, 2023
The Bible, banned in the state of Utah

The Bible, banned in the state of Utah

June 4, 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

  • Villacís assures that he will take advantage of the Vice Mayor’s office “until the last moment”
  • They locate the lifeless woman who disappeared on Friday in Mallorca
  • Fagerström, expert against smoking: “We can free the world from cigarettes, but not from nicotine”
  • 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.