← All benchmarksPython

Python __slots__: 92 MB vs 188 MB for 1 million objects

How much memory does __slots__ save in Python?

One million instances of a three-attribute class used 188 MB with a normal class and 92 MB with __slots__ (measured with tracemalloc).

Results

normal class188 MB
with __slots__92 MB

How it was measured

1,000,000 objects with attributes a, b, c.

class PS:
    __slots__ = ("a", "b", "c")

Why

__slots__ removes the per-instance __dict__.

When this does not apply

No dynamic attributes. Only worth it for millions of small objects.

Environment

MacBook Air (Apple silicon, 8 cores), macOS, Python 3.9. Measured 2026-10-12.

Source: shorts/demo-ticket/w2/slots.py in my content-engine repository. Treat any single run as a direction; re-run it on your hardware.

By Josué Barros, senior software engineer (full-stack, data and AI).