STINNER Victor <vstin...@python.org> added the comment:
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. ---------- nosy: +vstinner _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45155> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com