Message 294305 - Python tracker

Message294305

Author Aaron Hall
Recipients Aaron Hall, docs@python
Date 2017-05-24.01:01:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495587707.13.0.0998591622446.issue30449@psf.upfronthosting.co.za>
In-reply-to
Content
The __slots__ documentation in the datamodel needs improvement.

For example:

> When inheriting from a class without __slots__, the __dict__ attribute of that class will always be accessible, so a __slots__ definition in the subclass is meaningless.

The __slots__ definition for such a subclass is not meaningless: other slots declared will still be used, and the __dict__ will not be instantiated unless it is looked for (although this may be an implementation detail).

> The action of a __slots__ declaration is limited to the class where it is defined. As a result, subclasses will have a __dict__ unless they also define __slots__ (which must only contain names of any additional slots).

That's not quite right either. The action of a __slots__ declaration is not entirely limited to the class where it is defined. They can have implications for multiple inheritance, and child classes will have access to those slots.

I have some changes I'd like to make to the entire section on __slots__, and I'll be providing a pull request soon.
History
Date User Action Args
2017-05-24 01:01:47Aaron Hallsetrecipients: + Aaron Hall, docs@python
2017-05-24 01:01:47Aaron Hallsetmessageid: <1495587707.13.0.0998591622446.issue30449@psf.upfronthosting.co.za>
2017-05-24 01:01:47Aaron Halllinkissue30449 messages
2017-05-24 01:01:46Aaron Hallcreate