-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-45155 : Default arguments for int.to_bytes(length=1, byteorder=sys.byteorder) #28265
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
Conversation
This is a nice improvement. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks reasonable to me. But .format() instead of f-strings? What?!
The main docs need to be updated as well: https://docs.python.org/3/library/stdtypes.html?highlight=to_bytes#int.to_bytes |
Ha! I knew you'd say that 😆
Yep, thanks @rhettinger ... coming up! |
Also consider updating the default byteorder for int.from_bytes. The to/from round trip should be as symmetrical as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beat me to it! I agree that int.from_bytes
deserves the same treatment, too.
I also saw one possible improvement:
Please, for the sake of reproducible science (and other cases), don't add platform-dependent defaults. |
Co-authored-by: Brandt Bucher <[email protected]>
Misc/NEWS.d/next/Core and Builtins/2021-09-09-15-05-17.bpo-45155.JRw9TG.rst
Outdated
Show resolved
Hide resolved
When you're done making the requested changes, leave the comment: |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @brandtbucher: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one RST nit:
Co-authored-by: Brandt Bucher <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed some!
Misc/NEWS.d/next/Core and Builtins/2021-09-09-15-05-17.bpo-45155.JRw9TG.rst
Outdated
Show resolved
Hide resolved
When you're done making the requested changes, leave the comment: |
Co-authored-by: Brandt Bucher <[email protected]>
Co-authored-by: Brandt Bucher <[email protected]>
Co-authored-by: Brandt Bucher <[email protected]>
Co-authored-by: Brandt Bucher <[email protected]>
…55.JRw9TG.rst Co-authored-by: Brandt Bucher <[email protected]>
Thanks for catching the ones I missed @brandtbucher |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @brandtbucher: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I promise this is my last review!
Just realized that we can help AC give us a better __text_signature__
(for help
, inspect
, etc.). Other than that improvement, this looks good!
Co-authored-by: Brandt Bucher <[email protected]>
Co-authored-by: Brandt Bucher <[email protected]>
(I think you need to re-run AC locally, too.) |
@warsaw: Please replace |
In the PEP 467 discussion, I proposed being able to use
IOW, adding default arguments for the
length
andbyteorder
arguments toint.to_bytes()
It occurs to me that this is (1) useful on its own merits; (2) easy to do. So I've done it.
https://bugs.python.org/issue45155