-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from danigm/python313
Create 2024-09-11-python313.md
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
author: Daniel García Moreno | ||
date: 2024-09-11 08:00:00+20:00 | ||
layout: post | ||
license: CC-BY-SA-3.0 | ||
slug: python313 | ||
title: Python 3.13, with and without GIL | ||
image: /wp-content/uploads/2020/09/pythonlogo.png | ||
categories: | ||
- Announcements | ||
- Tumbleweed | ||
- openSUSE | ||
tags: | ||
- Python | ||
- openSUSE | ||
- SUSE | ||
- Developers | ||
- Open Source | ||
--- | ||
|
||
Python 3.13 RC2 is now available in Tumbleweed. This new version of | ||
the Python interpreter will be released in October 2024. | ||
|
||
There's [a lot of changes](https://www.python.org/downloads/release/python-3130rc2/) | ||
and new features in 3.13, but we're also bringing exiting experimental | ||
features in Tumbleweed. | ||
|
||
### Experimental JIT compiler | ||
|
||
The default (`python313`) build has the flag | ||
`--enable-experimental-jit=yes-off`. This means that if you want to | ||
use this [experimental JIT](https://docs.python.org/3.13/whatsnew/3.13.html#an-experimental-just-in-time-jit-compiler) | ||
you can enable with a environment variable: | ||
|
||
``` | ||
$ PYTHON_JIT=1 python313 | ||
``` | ||
|
||
You can find more information about the JIT compiler and how can this | ||
improve the performance in the | ||
[PEP-744](https://peps.python.org/pep-0744/). | ||
|
||
### Free threaded CPython (no GIL) | ||
|
||
With this new version of Python interpreter there's an option to build | ||
without the famous [Global Interpreter Lock](https://docs.python.org/3.13/whatsnew/3.13.html#free-threaded-cpython), | ||
aka GIL. This is a really experimental feature, but why not have this | ||
on Tumbleweed? So we decided to build also this new version with a new | ||
package `python313-nogil`. | ||
|
||
This new package is an isolated interpreter, so you can install | ||
without conflicts with `python313`. The package is building with the | ||
`--disable-gil` option and it provides the `/usr/bin/python3.13t` | ||
binary. It uses by default `/usr/lib/python3.13t/site-packages` for | ||
third-party libs, so with the default configuration it won't use any | ||
python 3.13 module. | ||
|
||
This means that now you can use `threading.Thread` in the Python | ||
interpreter and it will be actual threads, so at the end using threads | ||
with `python3.13t` interpreter should be a lot faster. | ||
|
||
There's no packages for this interpreter in Tumbleweed, at this | ||
moment. So if you want to use third party libraries you should use | ||
virtualenv and pip for that: | ||
|
||
``` | ||
$ python3.13t -m venv free-threaded-env | ||
$ source free-threaded-env/bin/activate | ||
(free-threaded-env) $ pip install requests | ||
(free-threaded-env) $ python3 | ||
Python 3.13.0rc2 experimental free-threading build (main, Sep 07 2024, 16:06:06) [GCC] on linux | ||
Type "help", "copyright", "credits" or "license" for more information. | ||
>>> import sys; sys._is_gil_enabled() | ||
False | ||
``` |