Skip to content
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

Use __slots__ for frequently created classes #153

Merged
merged 5 commits into from
May 28, 2024

Conversation

kirillgarbar
Copy link
Contributor

No description provided.

"""
Passed between uploading stages.
"""

__slots__ = "data", "upload_id"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add comment that @dataclasses support slots=True in python >= 3.10

repr_ = [f"{attr}: {getattr(self, attr)}" for attr in self.__slots__] # type: ignore
return f"{type(self).__name__}({repr_})"

def __eq__(self, other):
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add if not isinstance(other, self.__class__): return False for strictness

@Alex-Burmak
Copy link
Member

Moved fix for codespell errors to dedicated PR - #156

@aalexfvk aalexfvk merged commit 89ef858 into yandex:main May 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants