GIL & Threads.


The Global Interpreter Lock (GIL) in CPython allows only one thread to execute Python bytecode at a time. For CPU-bound tasks, threads usually provide no speedup. Processes bypass the GIL.

Threads (often no speedup for CPU-bound):

Alternative: Multiprocessing: