Interview Prep/Python for DevOps/Concurrency: threads, processes & asyncio

What is the GIL, and what does it mean for DevOps scripts?

IntermediateConceptConcurrency: threads, processes & asyncio
Answer

The Global Interpreter Lock in CPython allows only one thread to execute Python bytecode at a time. It is released during blocking I/O (network, disk, time.sleep, many C extensions), so threads give real speedups for I/O-bound work like API calls and SSH, and none for CPU-bound pure-Python work like hashing or parsing in a loop. For CPU-bound work use processes. Python 3.13 introduced an experimental free-threaded build (python3.13t) without the GIL, and 3.14 made it officially supported but optional; the default build still has the GIL.

All Python for DevOps questions Roadmap: Python for automation

More on Concurrency: threads, processes & asyncio