@classmethod
def from_int(cls, n, size=None, byteorder='little', signed=False):
    """
        buf.from_int(n[, size[, byteorder='little'[, signed=False]]])

        Convert an integer to a byte array.
        The optional size arguemnt determines the size of the resulting array
        (By default the size is the minimum possible).
        This function is made to be behaviorally compatible with Python 3's int.to_bytes.

        >>> buf.from_int(0x1234)
        buf(hex='3412')
        >>> buf.from_int(1, 4, 'big')
        buf(hex='00000001')
        """
    if size is None:
        bl = max(n.bit_length(), 1) + bool(signed)
        size = (bl + 7) // 8
    return cls._from_int(n, size, byteorder, signed)
