Can't set attribute?!

Bearophile bearophileHUGS at
Wed Sep 2 13:35:54 CEST 2009

dolgion ch:
>good to know about this __slots__ thing, i'll keep it in mind<

What you have to keep in mind is that it's better to not use __slots__
unless you really need to.
Generally you need it not for the purposes a person coming from a
static language is tempted to use it for. It's mostly useful for small
classes that don't need subclassing that have to be instantiated a
large number of times.

As far as I know, it's meant as a memory optimization, not a way to
define things in a more explicit way.


More information about the Python-list mailing list