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

only use __bytes__ when not argument is needed. #600

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

barbibulle
Copy link
Collaborator

The use of to_bytes should be reserved for cases where an argument is needed (like int.to_bytes()). For all other cases, __bytes__ should be used.
For legacy reasons, the code base still had a few places where to_bytes was called (and classes where both __bytes__ and to_bytes were defined).
This PR cleans up these cases.

@barbibulle barbibulle requested a review from zxzxwu November 23, 2024 23:58
Copy link
Collaborator

@zxzxwu zxzxwu left a comment

Choose a reason for hiding this comment

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

I personally prefer to_bytes since sometimes bytes() brings an additional indent. But it's also ambiguous with int.to_bytes().

@barbibulle barbibulle merged commit 4c3fd56 into main Nov 25, 2024
57 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.

2 participants