def is_gzip(path):
    """Test if a file is gzipped by reading its first two bytes and compare
    to the gzip marker bytes.
    """
    with open(path, 'rb') as f:
        marker_bytes = f.read(2)
    return marker_bytes[0] == 31 and marker_bytes[1] == 139
