Message401570
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')
b'\x00\x01'
>>> (1).to_bytes(1, 'big')
b'\x01'
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:54 | vstinner | set | recipients:
+ vstinner, barry, rhettinger, mark.dickinson, ncoghlan, petr.viktorin, ethan.furman, serhiy.storchaka, veky |
2021-09-10 11:06:54 | vstinner | set | messageid: <1631272014.58.0.175676511772.issue45155@roundup.psfhosted.org> |
2021-09-10 11:06:54 | vstinner | link | issue45155 messages |
2021-09-10 11:06:54 | vstinner | create | |
|