On 2021-09-08 13:37, Victor Stinner wrote:
On Wed, Sep 8, 2021 at 7:46 AM Steven D'Aprano <steve@pearwood.info> wrote:
>>> bytes.from_int(121404708502361365413651784, 'little') # should return b'Hello world'
Really? I don't know anyone serializing strings as a "bigint" number. Did you already see such code pattern in the wild? Usually, bytes are serialized as... bytes, no? Sometimes, bytes are serialized as base64 or hexadecimal to go through into an ASCII ("7-bit") bytestream. But I don' recall any file format serializing bytes as a single large decimal number.
Well, we already have int.from_bytes. What's that used for? Adding the opposite conversion does make sense to me. If the number is 0..255, and maybe the byteorder can be omitted in that case, then it seems like a reasonable solution to me.