ADITYA GUPTA
ADITYA GUPTA

Reputation: 51

How to disable the GIL in python3.13?

I am excited to experiment with python3.13 with new GIL optional feature. I want to explore the impact of disabling GIL to achieve real multi-threading in python. I want a real world example to compare the python3.13 performance for multi-threading with GIL enabled and disabled.

In the same environment, can i run two python one with GIL and other without GIL?

REF: PEP703

Upvotes: 3

Views: 2526

Answers (3)

Camilo Martínez M.
Camilo Martínez M.

Reputation: 1620

Fedora users can run the following, as explained here.

sudo dnf install python3.13-freethreading

This will install the interpreter at /usr/bin/python3.13t.

Upvotes: 1

Dj Mamana
Dj Mamana

Reputation: 384

Ubunt users can use:

sudo add-apt-repository ppa:deadsnakes
sudo apt-get update
sudo apt-get install python3.13-nogil

Upvotes: 1

Caio Salgado
Caio Salgado

Reputation: 349

According to the What's new in Python 3.13, you need a new Python binary to test it.

The free-threaded mode requires a different executable, usually called python3.13t or python3.13t.exe.

Using pyenv latest version to install Python, this should give you a virtual environment to test it (in most unix systems):

pyenv install 3.13t-dev
$HOME/.pyenv/versions/3.13t-dev/bin/python3.13t -m venv .venv
source .venv/bin/activate

You can check it with sys._is_gil_enabled()

python -c 'import sys; print(sys._is_gil_enabled())'
# you should get 'False'

Upvotes: 4

Related Questions