Logo

Question preview

del and __del__

What this preview is

About this preview

del and __del__ is a cracked quant interview question on language knowledge in Python.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

What this Python object lifecycle question tests

This is a Cracked-difficulty Python question that probes your understanding of object destruction, garbage collection, and the distinction between explicit deletion and finalization. It asks you to trace the execution of code involving the del statement and the __del__ dunder method to predict what gets printed.

To solve problems like this, you need to understand when objects are actually deallocated, how del affects reference counts, and whether __del__ is guaranteed to run immediately or deferred. Python's memory model here differs sharply from languages with deterministic destructors, and interviewers often use this gap to separate candidates who have merely read the docs from those who have reasoned through the behaviour.

  • Reference counting and the del statement
  • The __del__ finalizer method and its timing guarantees
  • Garbage collection and cycle detection
  • Edge cases: circular references, exceptions in __del__