__slots__ provides a small optimization of memory usage, as it may prevent __dict__ from __dict__ allocated for storing instance attributes. This can be useful if you have a lot of instances.
The restriction you are talking about is basically a random side effect of how it is implemented. In particular, this stops the creation of __dict__ if your class inherits a base class that does not have __dict__ (for example, object ), and even then it does not stop __dict__ to be allocated in any subclasses if they also do not define __slots__ . It is not intended as a security mechanism, so it is best not to try to use it as such.
All old-style classes receive __dict__ automatically, so __slots__ not valid. If you inherit from object , you will get the effect you are looking for, but basically don't worry about __slots__ until you find out that you have millions of instances and a memory problem.
Duncan
source share