clarify endianness

This commit is contained in:
Danny Ryan 2019-09-16 09:58:09 -05:00 committed by GitHub
parent ea6a3b293c
commit 9582814c62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

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