Skip to content

Add __slots__ to typing._NotIterable #92570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2022

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented May 9, 2022

4739997 added typing._NotIterable as a mixin to typing._SpecialForm, which defines __slots__ as an optimisation technique. However, typing._NotIterable does not define __slots__, meaning the the __slots__ declaration on typing._SpecialForm is now meaningless, since all base classes must define __slots__ in order for a __slots__ declaration on a subclass to have any effect.

This PR adds __slots__ = () to typing._NotIterable.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. (Though didn't we once try to assess the effect of those slots and failed to find any?)

@AlexWaygood
Copy link
Member Author

LGTM. (Though didn't we once try to assess the effect of those slots and failed to find any?)

Those were different slots I think :)

@kumaraditya303 kumaraditya303 added the needs backport to 3.11 only security fixes label May 10, 2022
@serhiy-storchaka serhiy-storchaka merged commit eef47d5 into python:main May 10, 2022
@miss-islington
Copy link
Contributor

Thanks @AlexWaygood for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-92617 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 10, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 10, 2022
(cherry picked from commit eef47d5)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood deleted the notiterable branch May 10, 2022 09:20
miss-islington added a commit that referenced this pull request May 10, 2022
(cherry picked from commit eef47d5)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants