Python Developer Interview Question

Can you explain what the GIL is and what it actually protects?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

The Global Interpreter Lock is a mutex in CPython that lets only one thread execute Python bytecode at a time, protecting interpreter state such as reference counts and internal object structures. It means threads do not give you parallel speedup for CPU bound Python code, but they still help with I/O, because the lock is released during blocking calls and C extension work.

Why interviewers ask this

It is the classic filter question for Python depth. Interviewers want to hear that you understand why threading helps I/O bound work and not CPU bound work, and that you can reach for multiprocessing or native extensions when you need real parallelism. Vague answers like Python cannot do threads signal someone who has memorized a slogan rather than reasoned about the runtime.

How to structure your answer

  • Define the GIL in one sentence.
  • Say what it protects and why CPython has it.
  • Contrast I/O bound and CPU bound work.
  • Name the escape hatches you actually use.

Example answer

Spoken example, first person

The GIL is a single lock in CPython that guarantees only one thread runs Python bytecode at any moment. It exists because reference counting is not thread safe, and a per object lock would be slower for the single threaded case that most code lives in. Practically, that means threads are great for waiting and useless for computing. On a data pipeline I worked on, we had a step pulling about eight hundred URLs, and moving that from a serial loop to a thread pool took it from roughly nine minutes to under one, because every worker spends its life blocked on a socket and releases the lock while it waits. The parsing step next to it saw no benefit at all, so we pushed that into a process pool instead. Numpy and other C extensions also drop the lock inside long running native calls, which is why heavy array math can look parallel even in threads. When someone tells me Python cannot do concurrency, I usually ask which kind they mean.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • So how does multiprocessing get around it?
  • What happens to the GIL when a C extension runs?
  • Have you looked at the free-threaded build?

Related python developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot