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

add explicit comments for int_to_bytes and bytes_to_int #1401

Merged
merged 3 commits into from
Oct 28, 2019

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Sep 7, 2019

Addresses #1395.
@mratsim is this what you meant? It seems a bit verbose as the initial header comment generally says the same thing. Can you remind me what exactly your issue was?

@JustinDrake
Copy link
Contributor

JustinDrake commented Sep 7, 2019

the initial header comment generally says the same thing

Agreed 😂

Also note that every """ comments are currently one-liners. There's no need to break this pattern, especially for such simple helper functions.

@mratsim
Copy link
Contributor

mratsim commented Sep 7, 2019

I think the best would be to give an example, for example, int_to_bytes(1, little_endian) returns 0x01000000...00000000

In our case we were padding the wrong way, i.e. something like this (exact location in byte 8 from the end)

0x00000000...01000000

@dankrad
Copy link
Contributor

dankrad commented Sep 8, 2019

I also feel like the naming of the functions and parameters makes their behaviour very obvious. And I am usually in favour of more verbosity.

I think the best would be to give an example, for example, int_to_bytes(1, little_endian) returns 0x01000000...00000000

I don't understand this, it's not a padding problem. Little endian literally means that the least significant byte comes first, so how was it confusing?

@djrtwo
Copy link
Contributor Author

djrtwo commented Sep 16, 2019

adjusted the comment to mention the endian-ness, but moved back to a 1-liner

@protolambda protolambda merged commit a6cecaf into dev Oct 28, 2019
@protolambda protolambda deleted the conversion-comments branch October 28, 2019 07:33
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.

5 participants