Intermediate Python
Q45 / 101

What is the purpose of __slots__?

Correct! Well done.

Incorrect.

The correct answer is B) To restrict attributes to a predefined list, reducing memory usage

B

Correct Answer

To restrict attributes to a predefined list, reducing memory usage

Explanation

__slots__ = ["x", "y"] prevents __dict__ creation per instance, saving memory when creating many small objects.

Progress
45/101