What this Python copy module question tests
This is a medium-difficulty question that probes your understanding of how Python's copy module handles object duplication. It's the kind of question interviewers ask to separate candidates who have internalized Python's memory and reference semantics from those who treat them as abstract concepts.
To reason through code like this, you need to distinguish between shallow and deep copying, understand how mutable objects (lists, dicts, custom classes) behave when duplicated, and predict what happens when nested structures are modified after copying. The question rewards careful tracing of object identity and mutation rather than guessing at output.
- Shallow copy vs. deep copy semantics
- Object identity and the
is operator - How mutable objects share references across copies
- Container nesting and copy propagation