With the release of Python 3.14, support for running multiple threads, in parallel, without each thread having to wait for the Global Interpreter Lock (GIL) is now supported.
I was keen to try this out, if only in a ‘hello world’ sense but it took me a little while to sort out what was necessary. In 3.14, and for some (perhaps “a lot of”) releases to come the GIL is enabled by default and if you wish to try out the new “GIL-less” world you have to compile an instance of Python while using the “disable-gil” flag.
Well it’s been some time since I’ve done anything other than installed canned versions of Python so I had remind myself how to do this.
The following describes my experience of a Linux/Bash environment but it should throw some light on other supported environments.
Although interested to 3.14 in action I certainly did want a freshly minted release to be my primary python so I needed a mean to install 3.14 alongside a more established version. Because I’d used it before I decided to use pyenv , a python version management tool that allows you to easily switch between different versions of python. If you don’t have it installed the instructions to do so are quite clear, don’t miss the changes to the environment variables after the install.
Once pyenv is in the place the rest is very straightforward, the key point is ensuring that the “–disable-gil” flag being used when compiling your new install.
rshea@jobabo:~/dev$ env PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-threads --enable-shared --disable-gil" pyenv install 3.14
Downloading Python-3.14.0.tar.xz...
-> https://www.python.org/ftp/python/3.14.0/Python-3.14.0.tar.xz
Installing Python-3.14.0...
Installed Python-3.14.0 to /home/rshea/.pyenv/versions/3.14.0
Now make 3.14 the active python.
rshea@jobabo:~/dev$ pyenv shell 3.14.0
And start python with the argument which ensures the GIL is not used.
rshea@jobabo:~/dev$ python -X gil-0
And within the REPL you can then check that the GIL is indeed disabled.
Python 3.14.0 free-threading build (main, Oct 12 2025, 16:11:53) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> status = sysconfig.get_config_var("Py_GIL_DISABLED")
>>> status
1
If you should find that the value of status is 0 then it’s worth checking the arguments you used to compile python with, you should be able to see ‘–disable-gil’ in the arguments displayed.
>>> import sysconfig
>>> print(sysconfig.get_config_var('CONFIG_ARGS'))
'--prefix=/home/rshea/.pyenv/versions/3.14.0' '--libdir=/home/rshea/.pyenv/versions/3.14.0/lib' '--enable-optimizations' '--with-threads' '--enable-shared' '--disable-gil' 'LDFLAGS=-L/home/rshea/.pyenv/versions/3.14.0/lib -Wl,-rpath,/home/rshea/.pyenv/versions/3.14.0/lib' 'LIBS=-L/home/rshea/.pyenv/versions/3.14.0/lib -Wl,-rpath,/home/rshea/.pyenv/versions/3.14.0/lib' 'CPPFLAGS=-I/home/rshea/.pyenv/versions/3.14.0/include'
>>> import sys
That’s all for now, my next step is to try Asyncio introspection capabilities but will have to wait for another day.
The image of wooden spools of thread is courtesy of : W.carter, and is used under CC BY-SA 4.0, via Wikimedia Commons.