Mike Hansen wrote: >>> - you can use __slots__ to restrict arbirtrary creation of >> (dynamic) >>> instrance attributes >> You can do this, but it is generally considered a misuse of >> __slots__ and potentially problematic. >> > > I'll bite. What is the proper/intended use of __slots__? Does it have > something to do with memory?
Yes, it is intended specifically to reduce memory consumption of objects that are going to be instantiated a lot. I'm not sure how many counts as a lot, but in the thousands at least. Using __slots__ saves the cost of the attribute dict for each instance. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor