This is the same functionality as ``int.from_bytes`` in python 3
500353
def _from_bytes(bytes, byteorder="big", signed=False):
    """"""
    return int.from_bytes(bytes, byteorder=byteorder, signed=signed)
342503
def int(self, *args):
        
        data = self.bytes(*args)
        if data is not None:
            if len(data) == 1:
                return struct.unpack("<B", data)[0]
            if len(data) == 2:
                return struct.unpack("<H", data)[0]
            if len(data) == 4:
                return struct.unpack("<L", data)[0]
            if len(data) == 8:
                return struct.unpack("<Q", data)[0]
            print("can't get int from %s" % hexdump(data))
1044331
public static int bytesToInt(byte[] b)
    {
        int i = (b[0] << 24) & 0xFF000000;
        i |= (b[1] << 16) & 0xFF0000;
        i |= (b[2] << 8) & 0xFF00;
        i |= b[3] & 0xFF;
        return i;
    }
229242
private static int intFromSubArray(final byte[] bytes, final int from, final int to) {
    final byte[] subBytes = Arrays.copyOfRange(bytes, from, to);
    final ByteBuffer wrap = ByteBuffer.wrap(subBytes);
    return wrap.getInt();
  }
1122412
def bytes(self, *args):
        
        if len(args) == 1 and isinstance(args[0], BTree.Cursor):
            cur = args[0]
        else:
            cur = self.btree.find('eq', self.makekey(*args))

        if cur:
            return cur.getval()
427445
def get_int(self):
        
        byte = self.get_bytes(1)
        if byte == max_byte:
            return util.inflate_long(self.get_binary())
        byte += self.get_bytes(3)
        return struct.unpack('>I', byte)[0]
340042
def fromints(cls, ints):
        """"""
        return cls.frombitsets(map(cls.BitSet.fromint, ints))
346753
def _get_int(data, position, dummy0, dummy1, dummy2):
    """"""
    end = position + 4
    return _UNPACK_INT(data[position:end])[0], end
1300531
def frombytes(self, bytes, offset=0):
        
        for b in bytes:
            self._buf[offset] = b
            offset += 1
508863
public static int bytesToInt(byte[] bytes, int offset) {
        // 
        int result = 0x00000000;

        int length;
        if (bytes.length - offset < 4) // maximum byte size for int data type
                                        // is 4
            length = bytes.length - offset;
        else
            length = 4;

        int end = offset + length;
        for (int i = 0; i < length; i++) {
            result |= (bytes[end - i - 1] & 0xff) << (8 * i); // TODO uudashr: CHECK FOR IMPROVEMENT
        }
        return result;
    }
360226
def int_to_bytes(int_value: int, length: int) -> bytes:
    
    if length == 1:
        fmt = "!B"
    elif length == 2:
        fmt = "!H"
    return pack(fmt, int_value)
802174
@GwtIncompatible("doesn't work")
  public static int fromBytes(byte b1, byte b2, byte b3, byte b4) {
    return b1 << 24 | (b2 & 0xFF) << 16 | (b3 & 0xFF) << 8 | (b4 & 0xFF);
  }
1058291
def num2bytes(x, bytes):
    
    if not isinstance(x, int):  # If it is another "thing", just return ZEROs
        return tuple([0] * bytes)

    x = x & ((2 << (bytes * 8)) - 1)  # mask the initial value
    result = ()

    for i in range(bytes):
        result += (x & 0xFF,)
        x >>= 8

    return result
863027
def bytes_to_int(byte_array, big_endian=True, signed=False):
    
    if six.PY3:
        order = 'little'
        if big_endian:
            order = 'big'
        return int.from_bytes(byte_array, byteorder=order, signed=signed)
    else:
        length = len(byte_array)
        if length == 1:
            code = 'B'
        elif length == 2:
            code = 'H'
        elif length == 4:
            code = 'L'
        elif length == 8:
            code = 'Q'
        else:
            raise Exception("bytes_to_int : length of byte_array should be 1, 2, 4, or 8")
        if big_endian:
            code = '>'+code
        else:
            code = '<'+code

        if signed:
            code = code.lower()
        return struct.unpack(code, byte_array)[0]
1146170
def intToBin(i):
    
    # divide in two parts (bytes)
    i1 = i % 256
    i2 = int(i / 256)
    # make string (little endian)
    return i.to_bytes(2, byteorder='little')
1036315
def int_to_bytes(int_, width = None):
	
	if(width == None):
		width = int_.bit_length()
	byts = math.ceil(width / 8)
	return bytes([ (int_ >> (shift * 8)) & 0xff for shift in range(byts)])
1034819
def bytes_to_int(b, order='big'):  # pragma: no cover
        """"""
        if six.PY2:
            # save the original type of b without having to copy any data
            _b = b.__class__()
            if order != 'little':
                b = reversed(b)

            if not isinstance(_b, bytearray):
                b = six.iterbytes(b)

            return sum(c << (i * 8) for i, c in enumerate(b))

        return int.from_bytes(b, order)