add explicit comments for int_to_bytes and bytes_to_int

This commit is contained in:
Danny Ryan 2019-09-07 14:03:32 -04:00
parent d1fe8f16fd
commit ea6a3b293c
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 3 additions and 0 deletions

View File

@ -560,6 +560,8 @@ def xor(bytes_1: Bytes32, bytes_2: Bytes32) -> Bytes32:
def int_to_bytes(n: uint64, length: uint64) -> bytes:
"""
Return the ``length``-byte serialization of ``n``.
``n.to_bytes(length, endianness)`` returns ``n`` in endianness-endian bytes padded out to length bytes.
"""
return n.to_bytes(length, ENDIANNESS)
```
@ -570,6 +572,7 @@ def int_to_bytes(n: uint64, length: uint64) -> bytes:
def bytes_to_int(data: bytes) -> uint64:
"""
Return the integer deserialization of ``data``.
``n.to_bytes(data, endianness)`` returns ``data`` as in integer intepretted in endianness-endian.
"""
return int.from_bytes(data, ENDIANNESS)
```