<commit_before>try:
    from functools import reduce
except ImportError:
    # not necesary in Python 2.x
    pass

if hasattr(bytes, 'fromhex'):
    # Python 3.x
    import binascii
    def fromhex(s):
        return bytes.fromhex(s)
    def tohex(bin):
        return binascii.hexlify(bin).decode('ascii')
else:
    # Python 2.x
    def fromhex(s):
        return s.decode('hex')
    def tohex(bin):
        return bin.encode('hex')

def tobytes(b_or_s):
    try:
        if isinstance(b_or_s, bytes):
            return b_or_s
    except NameError:
        if isinstance(b_or_s, str):
            return b_or_s
    return b_or_s.encode('utf8')

def compare_digest(a, b):
    if not isinstance(a, str) or not isinstance(b, str):
        raise TypeError
    if len(a) != len(b):
        return False
    return reduce(bool.__and__, map(lambda x: x[0] == x[1], zip(a, b)))
<commit_msg>use all() instead of reduce(operator.__and__, ...)<commit_after>try:
    from functools import reduce
except ImportError:
    # not necesary in Python 2.x
    pass

if hasattr(bytes, 'fromhex'):
    # Python 3.x
    import binascii
    def fromhex(s):
        return bytes.fromhex(s)
    def tohex(bin):
        return binascii.hexlify(bin).decode('ascii')
else:
    # Python 2.x
    def fromhex(s):
        return s.decode('hex')
    def tohex(bin):
        return bin.encode('hex')

def tobytes(b_or_s):
    try:
        if isinstance(b_or_s, bytes):
            return b_or_s
    except NameError:
        if isinstance(b_or_s, str):
            return b_or_s
    return b_or_s.encode('utf8')

def compare_digest(a, b):
    if not isinstance(a, str) or not isinstance(b, str):
        raise TypeError
    if len(a) != len(b):
        return False
    return all(map(lambda x: x[0] == x[1], zip(a, b)))

{'fraction_non_alphanumeric': 0.12011173184357542, 'fraction_numerical': 0.0067039106145251395, 'mean_word_length': 2.498046875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4067539', 'n_tokens_mistral': 633, 'n_tokens_neox': 617, 'n_words': 168}