New submission from Aaron Hall:

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.

----------
assignee: docs@python
components: Documentation
messages: 294305
nosy: Aaron Hall, docs@python
priority: normal
severity: normal
status: open
title: Improve __slots__ datamodel documentation
versions: Python 2.7, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30449>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to