code: 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)
docs: convert bytes to integer