Python 3.14.0 Alpha Is Now Available: Here’s What’s Included
Python's latest alpha release brings deferred annotation evaluation and clearer error messages, with more features expected over six months of testing.
Oct 31st, 2024 5:00am by
Featured image via Unsplash+.
- Deferred evolution of annotations
- Improved error messages
Deferred Evaluation of Annotations
The deferred evaluation of annotations means the annotations of functions, classes, and modules will no longer be eagerly evaluated and will be stored in special-purpose annotate functions and evaluated only when necessary. Annotate functions are a subset of evaluate functions and can be called to retrieve the annotations of an object. This change was added to help improve the performance of annotations and make them more useful. According to PEP 649, “The new annotationlib module provides tools for inspecting deferred annotations. Annotations may be evaluated in the VALUE format (which evaluates annotations to runtime values, similar to the behavior in earlier Python versions), the FORWARDREF format (which replaces undefined names with special markers), and the STRING format (which returns annotations as strings).” The new annotationlib module is called with a line similar to:
from annotationlib import get_annotations, Format
Improved Error Messages
The current improvement for error messages centers around unpacking assignments. If an unpacking assignment fails because of an incorrect number of variables, the improved error message now prints the number of values in more instances than in previous Python releases. Here’s an example: In the Python interpreter (which is accessed by typing python3), type:
x, y, z = 10, 20, 30, 40
The Next Step
As with any alpha release, it’s important to communicate with the developers. If there’s a feature missing that you believe would be a worthwhile addition, you can reach out to the email address: hugo@python.org with your suggestions. The next alpha release, which is 3.14.0a2 is set to be released on Nov. 19, 2024. If you’re interested in testing Python alpha 3.14, you can install it from source (on Linux), or download one of the installers (macOS, Windows 64-bit, Windows 32-bit, or Windows ARM64). Remember, this is an experimental release, so it should not be considered for production use. You can check back with the official Python blog for more information on the various alpha releases.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.