Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue30463

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Add __slots__ to ABC convenience class
Type:enhancementStage:resolved
Components:Library (Lib)Versions:Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Aaron Hall, cjw296, levkivskyi, rhettinger, serhiy.storchaka
Priority:normalKeywords:

Created on2017-05-24 20:41 byAaron Hall, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 1822mergedAaron Hall,2017-05-26 04:45
Messages (4)
msg294389 -(view)Author: Aaron Hall (Aaron Hall)*Date: 2017-05-24 20:41
We have __slots__ with other ABC's, seehttp://bugs.python.org/issue11333 andhttp://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 (inLib/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 changesetff48739ed0a3f366c4d56d3c86a37cbdeec600de 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
msg356740 -(view)Author: Chris Withers (cjw296)*(Python committer)Date: 2019-11-16 01:14
I will note that this means with:class BaseClass(ABC):    passclass MyDerivedClass(BaseClass):    def __init__(self, thing):        self.thing = thingthing = MyDerivedClass()thing now has both __slots__ and, evidently, a dict. That's a bit weird and confusing.
History
DateUserActionArgs
2022-04-11 14:58:46adminsetgithub: 74648
2019-11-16 01:14:18cjw296setnosy: +cjw296
messages: +msg356740
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
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp