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

convert int_to_bytes to little endian #564

Merged
merged 2 commits into from
Feb 8, 2019
Merged

convert int_to_bytes to little endian #564

merged 2 commits into from
Feb 8, 2019

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Feb 3, 2019

addresses #556

@djrtwo djrtwo requested review from hwwhww, JustinDrake and vbuterin and removed request for hwwhww February 3, 2019 00:42
# Read 3-bytes of `source` as a 24-bit big-endian integer.
sample_from_source = int.from_bytes(source[position:position + rand_bytes], 'big')
# Read 3-bytes of `source` as a 24-bit little-endian integer.
sample_from_source = int.from_bytes(source[position:position + rand_bytes], 'little')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sample_from_source = int.from_bytes(source[position:position + rand_bytes], 'little')
sample_from_source = int_to_bytes3(source[position:position + rand_bytes])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to convert bytes-to-int, not int-to-bytes. int.from_bytes is correct, but definitely very pythonic

Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh, sorry for the misreading.
And I added bytes_to_int in #576.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

k. will wait on #576 merge and add bytes_to_int here

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