python-varint
python-varint copied to clipboard
A basic varint implementation in python
Why do the results differ? ```py def show(bytearray): print("".join(fr"\x{format(x, '02x')}" for x in bytearray)) def _byte(b): return bytes((b, )) def encode(number): """Pack `number` into varint bytes""" buf = b'' while...
Using varint.encode(-1) makes the program indefinitely stall. Is this expected behaviour, because I really need to be able to write negative varints.
resolves #7
>>> varint.decode_bytes(b'\x8c\x01') 140 >>> varint.decode_bytes(b'\x8c\x01eee') 140 I'm not sure if that should raise exception, silently discard data (like it's now) or maybe return unparsed input?
encode and decode function should work like PutVarint and ReadVarint in golang