classification
Title: Add __slots__ to ABC convenience class
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Aaron Hall, levkivskyi, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-05-24 20:41 by Aaron Hall, last changed 2017-06-06 19:38 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1822 merged Aaron Hall, 2017-05-26 04:45
Messages (3)
msg294389 - (view) Author: Aaron Hall (Aaron Hall) * Date: 2017-05-24 20:41
We have __slots__ with other ABC's, see http://bugs.python.org/issue11333 and http://bugs.python.org/issue21421.

There are no downsides to having empty slots on a non-instantiable class, but it does give the option of denying __dict__ creation for subclassers. 

The possibility of breaking is for someone using __slots__ but relying on __dict__ creation in a subclass - they will have to explicitly add "__dict__" to __slots__. Since we have added __slots__ to other ABC's, 

I will provide a PR soon on this. Diff should look like this (in Lib/abc.py):

class ABC(metaclass=ABCMeta):
    """Helper class that provides a standard way to create an ABC using
    inheritance.
    """
- pass
+ __slots__ = ()

(I also want to add a test for this, and ensure other ABC's also have this if they don't.)
msg294420 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-05-25 00:46
This seems reasonable.
msg295297 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-06 19:34
New changeset ff48739ed0a3f366c4d56d3c86a37cbdeec600de by Serhiy Storchaka (Aaron Hall, MBA) in branch 'master':
bpo-30463: Add an empty __slots__ to abc.ABC.
https://github.com/python/cpython/commit/ff48739ed0a3f366c4d56d3c86a37cbdeec600de
History
Date User Action Args
2017-06-06 19:38:51serhiy.storchakasetstatus: open -> closed
versions: + Python 3.7
resolution: fixed
components: + Library (Lib)
type: enhancement
stage: resolved
2017-06-06 19:34:59serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg295297
2017-05-26 20:24:30levkivskyisetnosy: + levkivskyi
2017-05-26 04:45:34Aaron Hallsetpull_requests: + pull_request1908
2017-05-25 00:46:51rhettingersetnosy: + rhettinger
messages: + msg294420
2017-05-24 20:41:17Aaron Hallcreate