What is the output of the following code using __slots__ with inheritance?

Python Professional Hard

Python Professional — Hard

What is the output of the following code using __slots__ with inheritance?

Key points

  • Child classes without __slots__ inherit a __dict__ from parent classes
  • Memory savings of __slots__ are not preserved in child instances without __slots__
  • Defining __slots__ in child classes is necessary to maintain memory efficiency

Ready to go further?

Related questions