Python: In Python, which comparison about __slots__ is accurate?

Difficulty:

Easy

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

In Python, which comparison about __slots__ is accurate?

  1. There is no practical difference in behavior, performance, or maintainability when __slots__ is involved.
  2. __slots__ can improve memory characteristics for many tiny objects, while regular classes stay more flexible for dynamic attributes and certain tooling patterns.
  3. The oldest option related to __slots__ is always the right production choice regardless of workload or context.
  4. Differences around __slots__ are mostly cosmetic, so correctness and debugging quality do not really change.

Hint

Focus on the behavior or tradeoff, not just the keyword.

Answer and rationale

Correct answer: B. __slots__ can improve memory characteristics for many tiny objects, while regular classes stay more flexible for dynamic attributes and certain tooling patterns.

__slots__ can improve memory characteristics for many tiny objects, while regular classes stay more flexible for dynamic attributes and certain tooling patterns. This is the comparison that usually separates memorization from understanding.

Track: Python