Python 3.13 release, an overview of its major features

What is Python

Python is a high-level computer programming language. Its human-readable nature has attracted a large number of people over the years. As an interactive programming language, Python is liked by beginner users, who can see the results of their code in a moment.

It supports major platforms such as Windows, macOS, and Linux. With just a few clicks, the user can set up a Python coding environment.

This article teaches you about the major features introduced in the Python 3.13 release.

What is Python used for

Python is the main tool to write a prototype for an app or a project. Dynamic typing offers the developer the luxury of focusing on the logic of the code rather than its structure.

Python is heavily used in the web development industry. Open-source frameworks such as Django, Flask, Pyramid, etc provide the necessary utilities to develop web applications.

Data scientists use Python libraries such as Matplotlib, NumPy, Pandas, SciPy, TensorFlow, etc for data analysis and numerical computations.

Due to the existence of many Python high-quality open-source security tools and its scripting abilities Python has wide usage in the penetration testing field. Security experts use Python daily to test for the presence of vulnerabilities in various infrastructures.

Lately, Python scripting has been a hot topic in the DevOps community.

Python 3.13 release

Python 3.13 has been released with new features, bug fixes, and deprecations. This release ships with a new Python interpreter and experimental features. It removes the dead batteries too.

Major features in Python 3.13 release

This release of Python brings a new and improved Python interpreter, concurrent threads, improved locals() built-in function, improved docstring, Tier3 support for Android and IOS, and improved modules.

Python 3.13 ships with a new interactive interpreter

It’s worth noting that the new Python interpreter supports multiline code editing. Now you can write code in the interactive shell without the fear of making typos since you can move the cursor on any line and edit it.

The Python prompt in this new interpreter is colorized as well as the traceback.

python 3.13 colorized interactive prompt
Python 3.13 colorized interactive prompt
python 3.13 colorized exception traceback
Python 3.13 colorized traceback

The Python 3.13 interactive interpreter supports the clear command. The same way you clear the screen on the Linux console or the Windows command prompt you can now run clear in the interactive Python shell.

python 3.13 prompt clear command
Python 3.13 prompt clear command
python 3.13 interactive prompt
Clearing the screen in the Python 3.13 interactive prompt

Commands like help, exit, and quit can now be executed without the need to call them as functions.

python 3.13 help
Python 3.13 help command
python 3.13 help
Python 3.13 help on module time

The exit command is shown below.

python 3.13 exit command
Python 3.13 exit command

The ‘paste mode’ can be used to paste large blocks of code inside the Python 3.13 interactive prompt. To enter ‘paste mode’ just hit F3 on the keyboard.

python 3.13 paste mode
Python 3.13 paste mode

Paste the code and hit F3 to enter the interactive Python shell.

Python 3.13 interactive interpreter supports history browsing. To do so hit F2 on the keyboard.

Concurrent threads

Python 3.13 maximizes the computer’s processing power by running threads in parallel. Software designed with threading in mind will run faster on multi-core hardware.

The free-threaded mode in Python 3.13 disables the Global Lock Interpreter (GIL). It is an experimental feature and is not enabled by default. The free-threaded binaries are available for the Windows and Mac installer. These binaries can be downloaded during the normal installation of Python through the Advanced Options as shown below.

free-threaded binaries in Python 3.13
Check the Download free-threaded binaries (experimental) box

To verify if the free-threaded mode is enabled type the following in the Python 3.13 interactive console.

import sys
sys._is_gil_enabled()

In case the above code returns False the free-threaded mode is active in your Python 3.13 installation.

Python 3.13 improves the locals() built-in function

The previous implementation of locals() is slow and buggy. For example:

>>> class C:
...     x = 1
...     sys._getframe().f_locals['x'] = 2
...     print(x)
...

prints 2 but:

>>> def f():
...     x = 1
...     sys._getframe().f_locals['x'] = 2
...     print(x)
...
>>> f()

prints 1.

The above inconsistency is fixed in Python 3.13.

Python 3.13 improves locals()
Python 3.13 improves the locals() built-in function

Python 3.13 release automatically removes the leading whitespace in a docstring

The leading whitespace in a docstring is automatically removed by the compiler in Python 3.13. This reduces the size of the .pyc files.

python 3.7 docstring leading whitespace
Python 3.7 leading whitespace in docstring

python 3.12 leading whitespace in docstring
Python 3.12 leading whitespace in docstring

python 3.13 leading whitespace in docstring is removed
The leading whitespace in docstring is removed in Python 3.13

Android and IOS are now Tier 3 supported platforms

Considering that the next developers will spend a lot of time on a mobile device Python 3.13 officially supports IOS and Android platforms.

It’s important for the future of Python as a language to keep the existing users and attract new ones. So any platform that has widespread usage should be supported.

Improved error messages

Python 3.13 has improved error messages by providing useful information to the user. For example, in case you provide the wrong keyword argument to a function you are informed in the error message about the correct name.

python 3.13 improved error messages
Improved error messages in Python 3.13

It’s common and not only for beginners to name new scripts exactly as the standard modules in the Python library. Python 3.13 displays a helpful message in the error to inform the user to rename their module.

Deprecations

Python 3.13 removes many deprecated modules, some classes, and functions from the standard libraries and also schedules new removals for Python 3.15.

The following modules are removed in Python 3.13.

  • aifc
  • audioop
  • chunk
  • cgi
  • cgitb
  • crypt
  • imghdr
  • mailcap
  • msilib
  • nis
  • nntplib
  • ossaudiodev
  • pipes
  • sndhdr
  • spwd
  • sunau
  • telnetlib
  • uu
  • xdrlib
  • lib2to3
python 3.12 cgi module slated for removal in python 3.13
cgi module slated for removal in Python 3.13

 python 3.13 removes  the cgi module
Python 3.13 removes the cgi module

Final thoughts

Python 3.13 provides new utilities and improves the existing ones. Python users can take full advantage of the useful features in the new interactive interpreter as well as the performance offered in no-GIL binaries.

You can read more in the official release note.

1 thought on “Python 3.13 release, an overview of its major features

Leave comment

Your email address will not be published. Required fields are marked with *.