TNS
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
NEW! Try Stackie AI
Programming Languages / Python / Software Development

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
Featued image for: Python 3.14.0 Alpha Is Now Available: Here’s What’s Included
Featured image via Unsplash+.
Python developers get excited because the first alpha of version 3.14.0 of the widely popular programming language has been made available. Keep in mind, that this is an early developer preview and is the first of seven planned alpha releases, which are intended to make the testing of the current state of new features and bug fixes possible. As with any alpha release, features can still be added all the way up to the start of the beta phase, which is set to begin on 05/06/2025. In other words, the alpha phase is over six months, so there’s plenty of time to kick the tires, see what’s new, and (more importantly) report any bugs you might find. As with any point release, you shouldn’t expect major changes to the language or deal-making (or breaking) features. That doesn’t mean you won’t find something new in the release. In fact (according to the official Python blog), new features are still being planned and written, so there’s no telling what the future of this release may hold. At the moment, there are two major new features that have been added to Python 3.14.0 alpha, which are:
  • Deferred evolution of annotations
  • Improved error messages
Let’s take a quick look at each.

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
For those who’ve not used annotations in Python, they not only increase the readability of your code but also hint about the data types of the variables, function parameters, and return type. There are two types of annotations in Python: function annotations and variable annotations. A function annotation looks something like this: The above snippet accepts two parameters – a and b and then denotes the return type as <expression>. You would then access the annotations using the __annotations__ attribute like so:

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
In previous iterations of Python, the printed error would be: Traceback (most recent call last):   File “<python-input-0>”, line 1, in <module>     x, y, z = 10, 20, 30, 40     ^^^^^^^ ValueError: too many values to unpack (expected 3) In the 3.14.0 alpha, that error message would now read: Traceback (most recent call last):   File “<stdin>”, line 1, in <module>     x, y, z = 10, 20, 30, 40     ^^^^^^^ ValueError: too many values to unpack (expected 3, got 4) It gives you a little bit more information, which could go a long way to help you debug your code.

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.
Group Created with Sketch.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.