Here is the code:
>>> class A:
... __slots__ = ("a",)
... def __init__(self):
... self.a = 1
...
>>> class B:
... def __init__(self):
... self.b = 1
...
>>> import pickle as pk
>>> len(pk.dumps(A()))
40
>>> len(pk.dumps(B()))
36
>>> a = A()
>>> a.b = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'A' object has no attribute 'b'
A has the slots attribute, B does not, but A actually takes up more memory than B?