# \_\_slots\_\_

say it: **“DUN-der SLOTS”** **/ˈdʌndər ˈslɑts/**

Lists the only attributes a class's objects may have, saving memory.

## What does `__slots__` do?

`__slots__` lists the only attributes a class's objects may have. They use less memory, which adds up when you make millions of them.

```python
class Pixel:
    __slots__ = ("x", "y", "color")

    def __init__(self, x, y, color):
        self.x, self.y, self.color = x, y, color

p = Pixel(0, 0, "red")
p.size = 3   # AttributeError: not in __slots__
```

Level: Master · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=5)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/slots
