The new stable version of Python 3.12 arrives and these are its new features

python logo

Python is a high-level programming language.

After a year of development, The release of the stable version was announced and also the beginning of the alpha testing phase of the programming language Python 3.12 and Python 3.13 (respectively). It is mentioned that this new branch of Python 3.12 will be supported for a year and a half, after which, for another three and a half years, fixes will be generated to eliminate vulnerabilities.

The new version of Python 3.12 that is presented comes with improvements in the flexibility of f-string analysis. With this improvement now many restrictions can be left aside, since for example you can now contain any valid expression in Python, including multiline expressions, comments, backslashes, and Unicode escape sequences. Additionally, internal strings now allow reusing the same quotes i.e. double quotes can now be reused inside without having to change to single quotes.

For example :

f"""{f'''{f'{f"{1+1}"}'}'''}"""

It is now possible to nest arbitrarily:

f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}"

Another of the changes that stands out is the support for isolated subinterpreters and separate global locks, which are intended to increase the efficiency of resource use in multicore systems, since for different interpreters within a process CPython allows several interpreters to run at the same time in a process. As it stands, the feature is currently only available via C-API (Python API support will appear in the next major branch).

In addition to this, it is also highlighted thatThe informative content of error messages has been increased and the range of exceptions has been expanded, offering recommendations to eliminate typographical errors. For example, suggestions for importing forgotten standard library modules and suggestions for prefixing “self” are now displayed.

Added the ability to use the buffer protocol in Python code. Classes that provide a "__buffer__()" method can now be used as types that operate directly on binary data in memory.

The sys.monitoring is proposed for debugging and profiling, allowing you to monitor events in CPython such as calls, function returns, execution of arbitrary lines of code, exceptions and transitions with minimal overhead.

The interpreter implements support for the Linux kernel performance subsystem, which allows Python function names to be determined when profiling using the performance utility (previously, only C function names were determined in traces).

Regarding performance improvements, it is mentioned that optimizations continued, with which A total performance gain estimated at 5% has been obtained., it was also added experimental support for the BOLT binary optimizer to the build process, increasing performance by 1-5%, while the performance of the asyncio package has improved significantly (some tests show a 75% speedup).

Inline expansion of list comprehensions has been implemented, which speeds up working with list comprehensions by up to two times (for code that actively uses list comprehensions, testing showed an overall performance increase of 11%).

To improve security, built-in implementations of SHA1, SHA3, SHA2-384, SHA2-512 and MD5 algorithms in hashlib have been replaced with formally verified options from the HACL* project (built-in implementations are used only if OpenSSL is not available).

Of the other changes that stand out:

  • The module has expanded support for Windows.
  • Python implements stack overflow protection.
    The creation of the asyncio.Task class has been sped up.
  • The size of Unicode objects has been reduced by 8 to 16 bytes.
  • Operations with regular expressions re.sub(), re.subn() and re.Pattern have been sped up.
  • Running isinstance() checks for some protocols has been sped up by 2 to 20 times.
  • Significantly (in some tests up to 64%) the tokenize.tokenize() and tokenize.generate_tokens() functions have been sped up.
  • Attribute loading and calling the super() method have been sped up.
  • A new, more compact type annotation syntax has been proposed for generic classes and functions.
  • The web browser module no longer supports older browsers including Grail, Mosaic, Netscape, Galeon, Skipstone, Iceape, Firebird, and Firefox up to version 36.
  • In preparation for future optimizations, the internal representation of integers has been changed.

Last but not least, as mentioned, alpha testing of Python 3.13 has begun, in which a compilation mode appeared CPython without a global interpreter lock (GIL, Global Interpreter Lock).

The branch Python 3.13 will be in alpha for seven months, during which new features will be added and bugs fixed according to the new development schedule, work on a new branch begins five months before the release of the previous branch and by the time the next version reaches the testing stage alpha.

After this, the beta versions will be tested for three months, during which adding new features will be prohibited and all attention will be paid to fixing bugs. During the last two months before release, the branch will be in the release candidate stage, where final stabilization will take place.

Finally yes you are interested in knowing more about it, you can check the details in the following link


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.