Latest Changes in Python 3.12

Python 3.12, released on September 2, 2023, brings a plethora of new features, optimizations, and improvements.

Improved Error Messages

Python 3.12 introduces more informative error messages. For instance, if a NameError is raised, the interpreter will now suggest modules from the standard library that could resolve the issue. This feature aims to make debugging more straightforward and less time-consuming.

New Features

PEP 701: Syntactic Formalization of f-strings

This PEP lifts some restrictions on f-strings, allowing for more complex expressions, including multi-line expressions and comments. It also allows for the nesting of f-strings and the use of backslashes and Unicode characters.

PEP 709: Comprehension Inlining

This feature optimizes the execution of list, set, and dictionary comprehensions by up to 2x by inlining them, rather than creating a new single-use function object for each execution.

PEP 688: Buffer Protocol Accessibility

Python 3.12 introduces a way to use the buffer protocol directly from Python code, making it easier to work with buffer types.

PEP 684: A Per-Interpreter GIL

This PEP allows for the creation of sub-interpreters with a unique GIL per interpreter, enabling Python programs to take full advantage of multiple CPU cores.

New Features Related to Type Hints

PEP 692: TypedDict for **kwargs

This PEP allows for more precise typing of **kwargs by using TypedDicts.

PEP 698: Override Decorator for Static Typing

A new decorator, typing.override(), has been added to indicate to type checkers that a method is intended to override a method in a superclass.

PEP 695: Type Parameter Syntax

This PEP introduces a more compact and explicit way to create generic classes and functions.

Other Language Changes

  • Support for the Linux perf profiler has been added.
  • slice objects are now hashable.
  • sum() now uses Neumaier summation for improved accuracy when summing floats.

Optimizations and Improvements

Various modules like array, asyncio, calendar, csv, and others have received optimizations and new features, making Python 3.12 a robust and efficient version.


Python 3.12 is a significant update that brings many new features and improvements, making Python more powerful and easier to use. Whether you are a beginner or an experienced developer, this new version has something to offer for everyone.

For more details, you can visit the official Python 3.12 documentation.