Interview Preparation
Prepare for Python/Django interviews — core Python questions, Django internals, database design, and system design challenges.
50 min•By Priygop Team•Last updated: Feb 2026
Python Interview Topics
- Mutable vs Immutable: Lists, dicts, sets are mutable (can change). Strings, tuples, ints, frozensets are immutable. Default mutable arguments are shared: def f(lst=[]) is a bug — use def f(lst=None)
- GIL (Global Interpreter Lock): Only one thread executes Python bytecode at a time — threading doesn't help CPU-bound tasks. Use multiprocessing for CPU parallelism. Threading works for I/O-bound tasks
- __init__ vs __new__: __new__ creates the instance (class method, rarely overridden). __init__ initializes it (sets attributes). __new__ is useful for singletons and metaclasses
- Generators: yield keyword — function returns an iterator. Values computed lazily (one at a time, not all in memory). Memory efficient for large datasets. Used in Django querysets internally
- Django ORM vs Raw SQL: ORM for 90% of queries — readable, database-agnostic, prevents SQL injection. Raw SQL for complex queries the ORM can't express. Always profile slow queries with EXPLAIN
- *args, **kwargs: *args collects positional arguments as a tuple. **kwargs collects keyword arguments as a dict. Used in decorators, flexible function signatures, and forwarding arguments