Yahoo
Advertisement
Advertisement
Advertisement
Advertisement

Python 3.15 Gets Its First Alpha Build: Here's What's New

Python logo over blurred Python code background, with the word 'Python' written in yellow underneath.
Lucas Gouveia/How-To Geek

The release of Python 3.15.0 alpha 1 on GitHub marks the beginning of the official preview and testing phase for the next feature version of the language. This alpha release gives the first look at the new changes that will make the language faster and much easier to work with.

One of the biggest and most exciting new features in Python 3.15 is the new statistical sampling profiler. This is a massive change that's going to make a lot of developers' lives much easier. Unlike older deterministic profilers, which can slow down your code by instrumenting every function call, this offers virtually zero overhead. This is a game-changer for debugging performance issues, especially in production environments.

What makes this profiler so great is that it periodically captures stack traces from running Python processes instead of instrumenting every function call. You can attach it to any running Python process, so you won't need to modify your code or even restart the process to see what's going on. This is very fast, getting sampling rates of up to 1,000,000 Hz, which makes it the fastest sampling profiler for Python.

Advertisement
Advertisement

The profiler generates statistical estimates of time spent, providing real-time sampling stats, and is flexible enough to output both detailed statistics and flamegraph data. It can even handle thread-aware profiling, letting you profile all threads or just the main one.

Another major, and honestly long-overdue, language change is that Python now uses UTF-8 as the default encoding. This change is independent of your system's environment, which is a huge win for compatibility. For those of us who have dealt with messy encoding errors over the years, this means that most I/O operations without an explicit encoding will now automatically use UTF-8. Since UTF-8 has basically become the de facto standard for representing text on the web, in file formats, and in programming languages, this move makes a ton of sense.

Remember that if you want the best compatibility between different Python versions, you should still explicitly provide an encoding argument. However, if you really need to hold onto the previous behavior, you can disable Python's UTF-8 mode using an environment variable or a command-line option.

Python 3.15 also comes with some clever improvements to its error messages. The interpreter is getting a lot smarter, especially when it comes to AttributeError exceptions. If you try to access an attribute that doesn't exist, but a similar one is available through a member of that object, the error message will now give you a helpful suggestion. For example, if you have a Container object with an inner object that has an area property, and you mistakenly callcontainer.area, the error will now suggest: "Did you mean: 'inner.area'?".

Advertisement
Advertisement

Beyond that, some standard modules got a nice facelift. For example, the calendar pages that are generated by calendar.HTMLCalendar will now support dark mode and use the HTML5 standard for better accessibility. Similarly, difflib.unified_diff() now has an optional color parameter to get color output that looks similar to what you'd see in git diff.

This first alpha is already available on Github , and is the first step in a long road of pre-releases leading up to the final stable version. Keep in mind that the projected final release date is still a long way off, being October 1, 2026.

Source: Python Documents

Advertisement
Advertisement
Mobilize your Website
View Site in Mobile | Classic
Share by: