GIL Become Optional in Python 3.13 (geekpython.in)
from pnutzh4x0r@lemmy.ndlug.org to programming@programming.dev on 12 Aug 2024 17:26
https://lemmy.ndlug.org/post/970136

cross-posted from: lemmy.ndlug.org/post/970135

GIL or Global Interpreter Lock can be disabled in Python version 3.13. This is currently experimental.

Python 3.13 brings major new features compared to Python 3.12 and one of them is free-threaded mode, which disables the Global Interpreter Lock, allowing threads to run more concurrently.

The GIL will be disabled when you configure the Python with the –disable-gil option which is nothing but a build configuration (free threading build) at the time of installation.

This will allow optionally enabling and disabling GIL using the environment variable PYTHON_GIL which can be set to 1 and 0 respectively.

It will also provide a command-line option -X gil which can also be set to 0 (disable) and 1 (enable).

#programming

threaded - newest

stuckgum@lemmy.ml on 12 Aug 2024 17:44 next collapse

For multithreaded applications, just don’t use python.

xmunk@sh.itjust.works on 12 Aug 2024 17:58 next collapse

It is a bad language choice for that need but a lot of people don’t have a choice or aren’t the decision makers.

mox@lemmy.sdf.org on 12 Aug 2024 18:22 collapse

For multithreaded CPU-bound applications, just don’t use pure python, unless the intensive work is done in a compiled module. (Those have always been able to run without the GIL, there are a bunch of them in the standard library and other popular packages, and the API for writing custom ones is pretty good.)

FTFY

atzanteol@sh.itjust.works on 12 Aug 2024 23:02 collapse

Python performance sucks - use C if it matters.

FTFY

mox@lemmy.sdf.org on 13 Aug 2024 00:49 collapse

C is one option for writing compiled modules, but certainly not the only one.

More importantly, writing a moderate-sized program entirely in C when only a small fraction of it needs high-performance custom behavior is likely a poor use of time, both immediately and throughout the code’s life.

Dark_Arc@social.packetloss.gg on 12 Aug 2024 18:14 collapse

This is really going to change the game for certain applications!

Being able to thread Python properly is really going to help it compete with NodeJS and JVM workloads (especially if they continue to work on proper JIT for Python).