Interview Q&A / Python

INTERVIEW Q&A · 81 QUESTIONS

Python interview questions

Lists, dictionaries, generators, decorators and the Python questions asked in service-company and data roles.

  1. What is the GIL in Python, and when should you use threads versus multiprocessing?

    The Global Interpreter Lock in CPython lets only one thread run Python bytecode at a time, so threads do not speed up CPU-heavy pure Python code. Threads still work well for I/O-bound work, because the lock is released while waiting. For CPU-bound work, use multiprocessing. Python 3.13 added an optional, experimental free-threaded build without the GIL.

    AdvancedIn-depth5 min read