Which of the following correctly describes the behavior of `__slots__` in a Python class?

Python Professional Hard

Python Professional — Hard

Which of the following correctly describes the behavior of `__slots__` in a Python class?

Key points

  • `__slots__` reduces memory usage by avoiding the creation of a `__dict__` per instance
  • This feature is particularly useful when memory optimization is a priority
  • `__slots__` does not make attributes read-only or enable multiple inheritance without MRO conflicts

Ready to go further?

Related questions