<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ByteOrbit</title>
    <description>The latest articles on DEV Community by ByteOrbit (@byteorbit).</description>
    <link>https://dev.to/byteorbit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4270358%2F13dc751e-3000-4eb5-8b63-f7bb5579302f.png</url>
      <title>DEV Community: ByteOrbit</title>
      <link>https://dev.to/byteorbit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/byteorbit"/>
    <language>en</language>
    <item>
      <title>Python 3.14 Free Threaded: Install, Benchmark and the Packages That Re-enable the GIL</title>
      <dc:creator>ByteOrbit</dc:creator>
      <pubDate>Sat, 28 Nov 2026 08:31:21 +0000</pubDate>
      <link>https://dev.to/byteorbit/python-314-free-threaded-install-benchmark-and-the-packages-that-re-enable-the-gil-4bi5</link>
      <guid>https://dev.to/byteorbit/python-314-free-threaded-install-benchmark-and-the-packages-that-re-enable-the-gil-4bi5</guid>
      <description>&lt;h1&gt;
  
  
  Python 3.14 Free Threaded: Install, Benchmark and the Packages That Re-enable the GIL
&lt;/h1&gt;

&lt;p&gt;Python 3.14 is the first release where the free-threaded build is officially supported, not experimental. This guide to &lt;strong&gt;Python 3.14 free threaded&lt;/strong&gt; shows how to install it with uv, how to check that the GIL is really off, what scaling we measured on 8 cores, a race condition that only appears without the GIL, and which common packages still switch it back on.&lt;/p&gt;

&lt;p&gt;Tested with CPython 3.14.10 (both the default and the &lt;code&gt;3.14t&lt;/code&gt; free-threaded builds) installed through uv 0.13.9, on an 8-core Linux x86-64 machine. The commands and outputs below are from that machine. We could not build a Docker image there, so the container section is based on the same uv commands plus the official image tag list.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "free threaded" means in Python 3.14
&lt;/h2&gt;

&lt;p&gt;A normal CPython build has a global interpreter lock (GIL): only one thread runs Python bytecode at a time, so CPU-bound threads do not speed up. The free-threaded build removes that lock. Threads run in parallel on separate cores, at the cost of a different ABI, extra memory use and a small single-thread slowdown.&lt;/p&gt;

&lt;p&gt;The official Python docs describe it plainly: free-threaded execution allows full use of available processing power, "while not all software will benefit from this automatically", and some third-party packages with extension modules "will re-enable the GIL". On the pyperformance suite the docs put the average single-threaded overhead between about 1% on macOS aarch64 and 8% on x86-64 Linux.&lt;/p&gt;

&lt;p&gt;It is a separate interpreter, not a flag on the normal one. The binary is called &lt;code&gt;python3.14t&lt;/code&gt;. A wheel built for the normal interpreter (&lt;code&gt;cp314&lt;/code&gt;) will not load there; it needs a &lt;code&gt;cp314t&lt;/code&gt; build.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Python 3.14 free threaded with uv
&lt;/h2&gt;

&lt;p&gt;uv knows the &lt;code&gt;t&lt;/code&gt; suffix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv python install 3.14t
uv run --python 3.14t python -VV
uv venv --python 3.14t .venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;python -VV&lt;/code&gt; prints "free-threading build" in the version string. To check the GIL state in a running process, use the function the docs recommend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sysconfig&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sysconfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_config_var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Py_GIL_DISABLED"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 1 on a free-threaded build&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_is_gil_enabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                         &lt;span class="c1"&gt;# False when the GIL is off&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two answers differ on purpose. The config variable tells you what the build can do. &lt;code&gt;sys._is_gil_enabled()&lt;/code&gt; tells you what the process is doing right now. On our box:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.14.10  Py_GIL_DISABLED = 0  gil enabled = True     (default build)
3.14.10  Py_GIL_DISABLED = 1  gil enabled = False    (3.14t)
3.14.10  Py_GIL_DISABLED = 1  gil enabled = True     (3.14t with PYTHON_GIL=1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can force the lock back on with the &lt;code&gt;PYTHON_GIL=1&lt;/code&gt; environment variable or &lt;code&gt;-X gil=1&lt;/code&gt;, and off with &lt;code&gt;0&lt;/code&gt;. We confirmed &lt;code&gt;python -X gil=1&lt;/code&gt; reports the GIL as enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python 3.14 free threaded benchmark
&lt;/h2&gt;

&lt;p&gt;The test is deliberately simple: a recursive &lt;code&gt;fib(32)&lt;/code&gt; in N threads, with N from 1 to 4, timed with &lt;code&gt;time.perf_counter()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthreads&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthreads&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Results (the free-threaded numbers are from two runs, which agreed within noise):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Build&lt;/th&gt;
&lt;th&gt;1 thread&lt;/th&gt;
&lt;th&gt;2 threads&lt;/th&gt;
&lt;th&gt;4 threads&lt;/th&gt;
&lt;th&gt;Throughput vs serial at 4 threads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3.14 (GIL)&lt;/td&gt;
&lt;td&gt;0.15 s&lt;/td&gt;
&lt;td&gt;0.30 s&lt;/td&gt;
&lt;td&gt;0.60 s&lt;/td&gt;
&lt;td&gt;1.0x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.14t (GIL off)&lt;/td&gt;
&lt;td&gt;0.15 s&lt;/td&gt;
&lt;td&gt;0.15 s&lt;/td&gt;
&lt;td&gt;0.15 to 0.16 s&lt;/td&gt;
&lt;td&gt;3.6x to 3.9x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.14t, &lt;code&gt;PYTHON_GIL=1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;0.15 s&lt;/td&gt;
&lt;td&gt;0.30 s&lt;/td&gt;
&lt;td&gt;0.62 s&lt;/td&gt;
&lt;td&gt;1.0x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Four threads on the normal build take four times as long as one, because they queue on the lock. On 3.14t they all finish in about the time of one. Setting &lt;code&gt;PYTHON_GIL=1&lt;/code&gt; on the free-threaded interpreter brought the old behaviour straight back, which is a handy way to A/B test your own code.&lt;/p&gt;

&lt;p&gt;Single-thread speed was the same to two decimal places in this one benchmark. Do not read that as "no overhead": the docs' 1% to 8% average is across many workloads, and a different benchmark will show a gap.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not everything scales
&lt;/h3&gt;

&lt;p&gt;We also ran a thread pool hashing 8 buffers with &lt;code&gt;hashlib.sha256&lt;/code&gt; (300,000 rounds each, 64-byte inputs):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.14   1 / 4 / 8 workers: 0.56 s / 0.57 s / 0.54 s
3.14t  1 / 4 / 8 workers: 0.62 s / 0.84 s / 0.87 s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Neither build scaled, and the free-threaded one was slower with more workers. We did not dig into why, and we are not claiming a cause. The lesson is practical: measure the real workload. A pure-Python loop scaled almost linearly, a workload dominated by one C library call did not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The race condition you meet only without the GIL
&lt;/h2&gt;

&lt;p&gt;On the normal build, &lt;code&gt;count += 1&lt;/code&gt; from several threads usually looks fine, because a thread rarely gets switched out in the middle of the operation. Without the GIL it is a real race. We ran four threads that each did two million increments of a shared global:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.14   gil_enabled=True   expected 8000000, got 8000000
3.14t  gil_enabled=False  expected 8000000, got 2238627, lost 5761373
3.14t  gil_enabled=False  expected 8000000, got 2248157, lost 5751843
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same code with &lt;code&gt;threading.Lock&lt;/code&gt; around the increment returned the exact total on both builds (800,000 of 800,000 with fewer iterations). The Python docs say the same thing in softer words: built-in types such as &lt;code&gt;dict&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt; and &lt;code&gt;set&lt;/code&gt; have internal locks, but you should use &lt;code&gt;threading.Lock&lt;/code&gt; or other synchronization primitives "instead of relying on the internal locks of built-in types, when possible."&lt;/p&gt;

&lt;p&gt;If your code only worked because the GIL hid a race, free threading will expose it. Run your tests on 3.14t before you ship it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which packages re-enable the GIL
&lt;/h2&gt;

&lt;p&gt;Import a C extension that has not declared free-threading support and Python turns the GIL back on for the whole process, with a warning. We built a tiny extension without the &lt;code&gt;Py_mod_gil&lt;/code&gt; slot to see exactly what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'legacyext',
which has not declared that it can run safely without the GIL. To override this behavior and keep
the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
before: False
after okext: False        (module that declares Py_MOD_GIL_NOT_USED)
after legacyext: True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting &lt;code&gt;PYTHON_GIL=0&lt;/code&gt; kept it off after the same import, which can crash if the module is really not thread-safe, so treat it as a debugging tool and not a fix.&lt;/p&gt;

&lt;p&gt;For real packages, we created a 3.14t venv and installed with &lt;code&gt;--only-binary :all:&lt;/code&gt; so uv would not compile anything:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Result on 3.14t today&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;numpy 2.5.5&lt;/td&gt;
&lt;td&gt;installs, GIL stays off after import&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pydantic 2.14.4 (pydantic-core 2.50.5)&lt;/td&gt;
&lt;td&gt;installs, GIL stays off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fastapi 0.165.0, uvicorn 0.54.0&lt;/td&gt;
&lt;td&gt;install, GIL stays off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;httptools 0.9.0, uvloop 0.23.0&lt;/td&gt;
&lt;td&gt;install, GIL stays off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;orjson&lt;/td&gt;
&lt;td&gt;no binary wheel found; uv could not resolve one, and a source build failed on our box because it needs a Rust toolchain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;psycopg[binary]&lt;/td&gt;
&lt;td&gt;no binary wheel found&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That is a snapshot from 28 November 2026 on Linux x86-64, not a promise. Two trackers keep the live picture: &lt;a href="https://py-free-threading.github.io/tracking/" rel="noopener noreferrer"&gt;py-free-threading.github.io/tracking&lt;/a&gt; and &lt;a href="https://hugovk.github.io/free-threaded-wheels/" rel="noopener noreferrer"&gt;hugovk.github.io/free-threaded-wheels&lt;/a&gt;. The most useful check is the cheapest one: import every dependency in a fresh 3.14t venv and print &lt;code&gt;sys._is_gil_enabled()&lt;/code&gt; afterwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker and Python 3.14 free threaded
&lt;/h2&gt;

&lt;p&gt;There is no official free-threaded tag in the Docker library. The official Python image lists &lt;code&gt;3.14-slim-trixie&lt;/code&gt;, &lt;code&gt;3.14-trixie&lt;/code&gt;, &lt;code&gt;3.14-alpine&lt;/code&gt; and the other normal variants, but no &lt;code&gt;3.14t&lt;/code&gt;. A request for 3.13t and 3.14t images is still open as docker-library/python issue 1082. So &lt;code&gt;FROM python:3.14-slim&lt;/code&gt; gives you the GIL build, and setting &lt;code&gt;PYTHON_GIL=0&lt;/code&gt; on it does not help: the default interpreter aborts at startup with &lt;code&gt;Fatal Python error: config_read_gil: Disabling the GIL is not supported by this build&lt;/code&gt;, which is what we got on 3.14.10.&lt;/p&gt;

&lt;p&gt;Instead, install the interpreter with uv in your own image. This is the same flow as our &lt;a href="https://byteorbit.tech/blog/fastapi-dockerfile-uv" rel="noopener noreferrer"&gt;FastAPI Dockerfile with uv&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; debian:trixie-slim
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;UV_PYTHON_INSTALL_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/python
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; pyproject.toml uv.lock ./
&lt;span class="k"&gt;RUN&lt;/span&gt; uv sync --frozen --no-dev --python 3.14t
&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"uv"&lt;/span&gt;, &lt;span class="s2"&gt;"run"&lt;/span&gt;, &lt;span class="s2"&gt;"--no-sync"&lt;/span&gt;, &lt;span class="s2"&gt;"--python"&lt;/span&gt;, &lt;span class="s2"&gt;"3.14t"&lt;/span&gt;, &lt;span class="s2"&gt;"python"&lt;/span&gt;, &lt;span class="s2"&gt;"-m"&lt;/span&gt;, &lt;span class="s2"&gt;"app"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We did not build this exact image because the box has no Docker daemon access, but we ran the same &lt;code&gt;uv lock&lt;/code&gt;, &lt;code&gt;uv sync --frozen --no-dev --python 3.14t&lt;/code&gt; and &lt;code&gt;uv run --no-sync --python 3.14t python -m app&lt;/code&gt; steps on a small project that depends on fastapi and uvicorn, and the app printed &lt;code&gt;gil enabled: False&lt;/code&gt;. Check your own build once. For a workspace with several packages, the &lt;a href="https://byteorbit.tech/blog/uv-workspace" rel="noopener noreferrer"&gt;uv workspace guide&lt;/a&gt; shows how to sync one member. A startup check is worth adding to the app itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_is_gil_enabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"GIL got re-enabled by an import"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put it after your imports in the entry point, so a dependency that silently re-enables the lock fails the deploy instead of the benchmark. In a FastAPI app the &lt;a href="https://byteorbit.tech/blog/fastapi-lifespan" rel="noopener noreferrer"&gt;lifespan hook&lt;/a&gt; is a natural place for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  When free threading is worth it
&lt;/h2&gt;

&lt;p&gt;Good fits: CPU-bound pure-Python work you currently split across processes (shared memory without pickling), thread pools doing parsing or transformation, and numerical code that calls into already-supported libraries from many threads.&lt;/p&gt;

&lt;p&gt;Poor fits: I/O-bound services. Threads waiting on a network call already release the GIL, so &lt;code&gt;asyncio&lt;/code&gt; or normal threads were fine before. If your app mostly calls a model endpoint, as in our &lt;a href="https://byteorbit.tech/blog/docker-compose-models" rel="noopener noreferrer"&gt;Docker Compose models guide&lt;/a&gt;, free threading will not make those calls faster. It also changes memory use: the docs warn that all interned strings become immortal, &lt;code&gt;None&lt;/code&gt; takes 32 bytes instead of 16 on x86-64, and freed memory can be returned later because of deferred reclamation.&lt;/p&gt;

&lt;p&gt;A sensible rollout: run your test suite on 3.14t in CI next to the normal build, add the GIL assertion, fix the locks it exposes, and only then benchmark production-shaped load.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I install Python 3.14 free threaded?
&lt;/h3&gt;

&lt;p&gt;With uv: &lt;code&gt;uv python install 3.14t&lt;/code&gt;, then &lt;code&gt;uv run --python 3.14t python -VV&lt;/code&gt; or &lt;code&gt;uv venv --python 3.14t&lt;/code&gt;. On macOS and Windows the official installers have an optional free-threaded build, and the binary is named &lt;code&gt;python3.14t&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I check whether the GIL is disabled?
&lt;/h3&gt;

&lt;p&gt;Call &lt;code&gt;sys._is_gil_enabled()&lt;/code&gt;. It returns &lt;code&gt;False&lt;/code&gt; when the GIL is off. &lt;code&gt;sysconfig.get_config_var("Py_GIL_DISABLED")&lt;/code&gt; only tells you the build supports it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did the GIL turn back on after an import?
&lt;/h3&gt;

&lt;p&gt;A C extension did not declare that it can run without the GIL, so Python enabled the lock for the whole process and printed a RuntimeWarning. Update the package, find a free-threaded wheel, or avoid it. &lt;code&gt;PYTHON_GIL=0&lt;/code&gt; forces it off but is unsafe for modules that are not thread-safe.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is there a free-threaded official Docker image?
&lt;/h3&gt;

&lt;p&gt;Not at the time of writing. The official Python image has no &lt;code&gt;3.14t&lt;/code&gt; tag and the request is still open. Install &lt;code&gt;3.14t&lt;/code&gt; with uv in your own image.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is free-threaded Python faster?
&lt;/h3&gt;

&lt;p&gt;For CPU-bound threaded code, yes: our 4-thread test finished in the time of one on 3.14t and four times as long on the normal build. Single-threaded code can be slightly slower, and some workloads, like our hashing test, did not scale at all.&lt;/p&gt;




&lt;p&gt;Official docs: &lt;a href="https://docs.python.org/3.14/howto/free-threading-python.html" rel="noopener noreferrer"&gt;Python support for free threading&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published on &lt;a href="https://byteorbit.tech/blog/python-314-free-threaded" rel="noopener noreferrer"&gt;ByteOrbit&lt;/a&gt;.&lt;br&gt;
title: &lt;br&gt;
published: false&lt;br&gt;
description: &lt;br&gt;
tags: &lt;/p&gt;

&lt;h1&gt;
  
  
  cover_image: &lt;a href="https://direct_url_to_image.jpg" rel="noopener noreferrer"&gt;https://direct_url_to_image.jpg&lt;/a&gt;
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Use a ratio of 100:42 for best results.
&lt;/h1&gt;

&lt;h1&gt;
  
  
  published_at: 2026-11-28 08:31 +0000
&lt;/h1&gt;




</description>
      <category>python</category>
      <category>docker</category>
      <category>performance</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
