Q1. What is the GIL in Python and how does it affect multithreading?
The Global Interpreter Lock is a mutex in CPython that allows only one thread to execute Python bytecode at a time. This means Python threads cannot run truly in parallel on multiple CPU cores for CPU-bound tasks. However threads are still useful for I/O-bound tasks because the GIL is released during blocking I/O operations like network calls or file reads. For CPU-bound parallelism use the multiprocessing module which creates separate processes with separate GILs. Python 3.13 is introducing per-interpreter GIL as an experimental option.