Python 3.13.0 Released! New Interactive Shell & Free-threaded Mode

Last updated: October 9, 2024 — Leave a comment

Python, the popular free open-source programming language, finally announced 3.13.0 stable this Monday!

Python 3.13 introduced new interactive shell. It’s enabled by default and based on code from the PyPy project.

When you start the new shell in an interactive terminal, it uses colors by default for prompts and tracebacks and supports multi-line editing.

As well, it supports REPL-specific commands such as help, exit, and quit without call them as functions. And, I can finally use clear command in the shell to clear screen.

The new interactive shell also supports interactive help browsing using F1, history browsing using F2, and ‘paste mode’ with F3 for pasting larger blocks of code.

Just in case for those who don’t like the new shell, it can be disabled by setting environment variable. PYTHON_BASIC_REPL=1.

Python 3.13 shell, with colors, multi-line editing, etc support

CPython now has experimental support for free-threaded mode, with the global interpreter lock (GIL) disabled. This mode allows running threads in parallel on available CPU cores. Though, it requires a different executable, usually called python3.13t or python3.13t.exe.

The free-threaded mode so far is an experimental feature and disabled by default. The official Windows and macOS installers provide option to enable this feature, and user can manually build CPython from source with the --disable-gil option, though it requires the new modified version of mimalloc, which is enabled by default on supported platform.

image from python.org

Other changes in Python 3.13.0 include an experimental just-in-time (JIT) compiler, which may speed up some Python programs, new dbm.sqlite3 backend in dbm module, that is used by default when creating new files.

And, the compiler now strips common leading whitespace from every line in a docstring, which reduces the size of the bytecode cache (such as .pyc files).

  • Raise macOS support version from 10.9 to 10.13 (High Sierra)
  • WASI is now a Tier 2 supported platform, iOS and Android are now Tier 3 supported platform.
  • Type defaults for type parameters
  • New type narrowing annotation, typing.TypeIs.
  • A new annotation for read-only items in TypeDicts.
  • A new annotation for marking deprecations in the type system.

The release also removed some old deprecated modules, classes, functions, methods, and C APIs. See here, here and here for details. And, see the full-changelog for more about Python 3.13.0.

How to Get Python 3.13.0

The official installer for Windows and macOS, as well as the source tarball are available to download in the Python website via the link below:

For Ubuntu , there’s a popular deadsnakes PPA which has been maintaining the most recent Python packages for several years. And, it now contains Python 3.13.0 for Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04.

To add the PPA & install Python 3.13.0, just open terminal (Ctrl+Alt+T) and run the commands below one by one:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.13-full

Or see this step by step guide which also taught how to built it from source tarball.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*