Python 3.13 Beta: The New Features and Fixes Coming Soon

Python 3.13 Beta: The New Features and Fixes Coming Soon
Photo by Kevin Ku / Unsplash

The first release of Python 3.13 is now here as a Beta Release. This article is a rundown of all of the important changes and features that are being released in Python 3.13, along with what they mean for Python Developers. Please remember that this can change between the time of posting this and when the production release comes out. With this release, all major features, additions, and changes are now officially frozen – which means no major changes will come to this release.

The New Features are here!

This is a quick look at the new features that are coming to Python 3.13 with this beta release, and hopefully the production release also.

  • The experimental JIT
  • The no-GIL build of Python
  • A new REPL
  • Improved error messages
  • Enhancements to Python types
  • No more "dead batteries"

The Experimental JIT

When Python 3.11 originally came out, it introduced the Specializing Adaptive Interpreter along with the release. This means that when the interpreter detects some operations predictably involves the same types, those operations are determined to be specialized. The generic bytecode that is used for the code is then swapped with bytecode that is specific to working with those types. This is where the speed boosts kick in between 15% to 40% for those regions of application code.

With the release of Python 3.12, we got even more specializations and other refinements to the Python interpreter. Now, with the release of Python 3.13 coming very soon, it is adding more and new elements to the JIT. This means that it is going to generate actual machine code at the runtime instead of just generating specialized bytecode. The results from this is speeding up application code even more – as of right now, we are only gaining about 5% performance boost, but it will pave the way for future optimizations that were not possible before.

Do you like what you are reading so far? When you are done with this article, we recommend reading Simple Implementation to Understand worker_threads in NodeJS as the next article you read.
Simple Implemention to Understand worker_threads in NodeJS
One of the most highly request features in the NodeJS runtime environment is being able to use multiple cores — a lot of programmers don’t exactly understand the availability of NodeJS packages available to use to help with this issue. The package is worker_threads. This package really does help fix

As of right now, the changes to the JIT are considered to be experimental. This means that they are not enabled by default, but can be enabled by compiling CPython from source with certain flags. If in the case that it yields a significate performance boost – meaning around 5% or more while not imposing a large management burden on Python Developers as a whole – it will become a fully supported build option for people to use. It is still up for debate if it will be enabled for official releases because it will be up the managers of the given platform of the CPython builds.

The Release Cycle of Python

The Python Programming Language is known for releasing new versions once a year every year. This also includes a feature locked beta in the first half of the year, then the final release towards the end of the year. The Python Core Developers encourage people to try out the latest release version on non-production environments. The goal of this is to make sure and to verify that your software applications works with the latest release and benefit from the new features, increased security, and along with performance boosts.

The Global Interpreter Lock (GIL)

The official term for possible future versions of CPython with no Global Interpreter Lock (or better known as GIL) is free-threaded CPython. This CPython build allows threads to run fully in parallel, without mediation from the GIL. This means that CPU-bound work that once only benefited from being run in multiple processes can run in multiple threads.

Free-threaded CPython is also highly experimental right now.This also means that it is not enabled by default in the shipped builds, so it needs to be enabled at compile time. If future work with the free-threaded builds shows it can improve multithreaded performance without impacting single-threaded performance, it'll be promoted to a fully supported option. In time, the free-threaded build of CPython may become the default.

The Brand New REPL

The Read, Evaluate, Print, and Loop (REPL), or Interactive Interpreter, launches when you run Python from the command line without the need of executing a program. Python 3.13's REPL has enhancements to make it less stodgy and more like an actual editor:

  • Output to the console now has color enabled by default. This enhancement provides richer error messages, for instance.
  • You can open the interactive pydoc help browser by pressing F1.
  • You can browse the command-line history with F2.
  • You can paste large blocks of code more easily by pressing F3 to enable a special block-paste mode.
  • You can just type exit or quit, instead of exit() or quit(), to leave the REPL.

Please note that the improvements above are only supported in Linux and MacOS of right now. They are not currently available on Windows – this also includes within the new Windows Terminal console host application.

Error Message Improvements

I am proud to write about error traces in Python have become more precise and detailed over the last two releases. Python 3.13 continues on that trajectory with the following changes and improvements.

  • If you attempt to import something that has the same name as the module currently in context, Python will provide a detailed error to that effect, and encourage you to rename the current module. This is a very frequent source of bugs — and not only for beginners. It's a common mistake to name a module after something in the standard library.
  • If you pass a function an incorrect keyword argument, the error will suggest some possible correct arguments, based on what's available in the function being called.

Python Types are Enhanced

I can not forget to write about python's type hinting system has been expanded in functionality and utility with each new version so far. The new version, Python 3.13 adds three big new changes that are worth writing about.

Type parameters support defaults

typing.TypeVartyping.ParamSpec, and typing.TypeVarTuple all let you define defaults to be used if no type is explicitly specified. For instance:

T = TypeVar("T", default=str)

In cases where T is not explicitly defined when used, str is assumed to be the default.

typing.TypeIs for type narrowing

In Python generally, we can use isinstance() to make decisions based on whether or not something is a given type. typing.TypeIs lets us do the same thing in Python's type hinting mechanisms. This way, functions used to validate whether or not something is a given type can be annotated to show they perform that narrowing behavior, rather than just a return type. This is useful as a way to add precise type checker coverage to those functions.

typing.ReadOnly for read-only annotation

The typing.TypedDict type was created to annotate dictionaries with fixed types for the values associated with certain keys. typing.Readonly lets you annotate specific values in a TypedDict as read-only. An example is a list that you can only append to or pop from, not replace with a string or other type.

No more dead batteries

With the release of Python 3.11, it has identified a slew of Python standard library modules that were obsolete and no longer being maintained. The plan was to mark them as deprecated for releases 3.11 and 3.12, then to remove them entirely in 3.13. As of right now, those dead batteries – as they've been called by Python Developers – are now officially and permanently removed. Many of the removed modules can be easily replaced with third-party modules, or their functionality can be emulated using other standard library components.

Python Developers can expect more deprecations to come over the next three major version releases of Python that are to come. Most are methods for various standard library components that are very rarely used or undocumented.

Do you like what you're reading from the CoderOasis Technology Blog? We recommend reading our Implementing RSA in Python from Scratch series next.
Implementing RSA in Python from Scratch
Please note that it is essential for me to emphasize that the code and techniques presented here are intended solely for educational purposes and should never be employed in real-world applications without careful consideration and expert guidance. At the same time, understanding the principles of RSA cryptography and exploring various

The CoderOasis Community

Did you know we have a Community Forums and Discord Server? which we invite everyone to join us? Want to discuss this article with other members of our community? Want to join a laid back place to chill and discuss topics like programming, cybersecurity, web development, and Linux? Consider joining us today!