You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,14 @@ Make multi-threaded concurrency backward- and forward-compatible for the free-th
5
5
6
6
---
7
7
8
-
### What?
8
+
### Introduction
9
9
10
10
`ConditionalThreadPoolExecutor` is a drop-in replacement for `ThreadPoolExecutor`
11
-
that automatically adapts to the runtime environment.
11
+
that adapts to the runtime environment. When running under free-threaded Python with the GIL disabled (3.14t) it behaves like a normal thread pool. However, when running under a GIL-enabled build, it falls back on single-threaded execution.
12
12
13
-
When running under **free-threaded Python (3.13t)** or when threads
14
-
are actually useful, it behaves like a normal thread pool.
13
+
The reason this is necessary is that CPU-bound processes that use multi-threading with the GIL can be much slower than single-threaded execution.
14
+
`ConditionalThreadPoolExecutor` permits having a single implementation that will perform optimally regardless of if the GIL is enabled or not.
15
15
16
-
When running under a traditional GIL build, it **falls back to single-threaded**
17
-
execution to avoid detrimental thread overhead.
18
16
19
17
### Why?
20
18
@@ -25,6 +23,24 @@ ConditionalThreadPoolExecutor detects when threads will be ineffective and avoid
0 commit comments