Understanding Python's object construction methods
This is a medium-difficulty Python language question that tests your understanding of the distinction between __new__ and __init__—two critical methods in Python's object lifecycle. Quant shops and trading firms use such questions to confirm that candidates have a solid grasp of low-level Python mechanics, not just surface-level syntax.
The question requires you to reason carefully about when each method is called, what each one returns, which one receives the class vs. the instance, and how they interact in both normal and edge-case scenarios. A correct answer demands clarity on the order of execution, the role of each method in instantiation, and common misconceptions that trip up less careful developers.
- Object instantiation flow and the role of metaclasses
- Return values and side effects of __new__ vs __init__
- Immutable types and singleton patterns
- Inheritance and cooperative multiple dispatch