Message271488
It will be nice if `int.to_bytes` be able to automatically choose number of bytes to serialize. If so, I could write serialisation code:
def serialize(value: int, signed=True) -> bytes:
x = value.to_bytes(-1, 'big', signed=signed)
l = value.to_bytes(4, 'big', signed=False)
return l + x
assert len(serialize(0)) == 4 + 0 # see Issue27623
assert len(serialize(120)) == 4 + 1
assert len(serialize(130)) == 4 + 2
assert len(serialize(130), False) == 4 + 1 |
|
Date |
User |
Action |
Args |
2016-07-28 03:15:12 | socketpair | set | recipients:
+ socketpair |
2016-07-28 03:15:12 | socketpair | set | messageid: <1469675712.56.0.174576481029.issue27637@psf.upfronthosting.co.za> |
2016-07-28 03:15:12 | socketpair | link | issue27637 messages |
2016-07-28 03:15:12 | socketpair | create | |
|