Logo

Question preview

Slothful __slots__

What this preview is

About this preview

Slothful __slots__ is a medium 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.

Understanding Python __slots__ and memory management

This is a medium-difficulty Python language question that tests whether you understand how __slots__ constrains attribute storage and what happens when code tries to violate those constraints. It is the kind of detail that separates candidates who have only read Python tutorials from those who have shipped production code.

To reason through this problem, you need to recall how Python normally stores instance attributes in a __dict__, how __slots__ changes that mechanism, and what error or behavior results when you attempt to assign an attribute that was not declared in the slots. The question rewards precise knowledge of Python's memory model and error handling, not guesswork.

  • Instance attribute storage and the __dict__ mechanism
  • How __slots__ restricts the set of allowable attributes
  • AttributeError and runtime behavior under constraint violation