13. Slots for Memory Optimization
__slots__ restricts attributes and reduces memory usage by preventing the creation of __dict__.
Example
class Point:
__slots__ = ("x", "y")
def __init__(self, x, y):
self.x = x
self.y = y
p = Point(1, 2)
print(p.x, p.y)
Wrap-Up
Use __slots__ for classes with many instances to save memory, but it removes dynamic attributes.