This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients barry, ethan.furman, mark.dickinson, ncoghlan, petr.viktorin, rhettinger, serhiy.storchaka, veky, vstinner
Date 2021-09-10.11:06:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I dislike the idea of adding a default length to int.to_bytes(). The length changes the meaning of the output:

>>> (1).to_bytes(2, 'big')
>>> (1).to_bytes(1, 'big')

If the intent is to "magically cast an integer to a byte strings", having a fixed length of 1 doesn't help:

>>> (1000).to_bytes(1, "big")
OverflowError: int too big to convert

If the intent is to create a bytes string of length 1, I'm not sure that "re-using" this existing API for that is a good idea.
Date User Action Args
2021-09-10 11:06:54vstinnersetrecipients: + vstinner, barry, rhettinger, mark.dickinson, ncoghlan, petr.viktorin, ethan.furman, serhiy.storchaka, veky
2021-09-10 11:06:54vstinnersetmessageid: <>
2021-09-10 11:06:54vstinnerlinkissue45155 messages
2021-09-10 11:06:54vstinnercreate