<commit_before>"""JSONquick
Faster JSON dumps"""

def dumps(props):
    s = "{"
    for k,v in sorted(props.iteritems()):
        typ = type(v)
        s += '"' + k + '": '
        if typ in [str, unicode]:
            s += '"' + str(v) + '"'
        elif typ == bool:
            s += ["false","true"][v]
        else:
            s += str(v)
        s += ", "
    s = s[:-2] + "}"
    return s<commit_msg>Fall back to default json.dumps() on error (Unicode!)<commit_after>"""JSONquick
Faster JSON dumps"""

import json
import logging

def dumps(props):
    try:
        s = "{"
        for k,v in sorted(props.iteritems()):
            typ = type(v)
            s += '"' + k + '": '
            if typ in [str, unicode]: 
                s += '"' + str(v) + '"' #   Gets a decodeerror on some Unicode strings for reasons I can't fathom
            elif typ == bool:
                s += ["false","true"][v]
            else:
                s += str(v)
            s += ", "
        s = s[:-2] + "}"
        return s
    except:
        return json.dumps(props, sort_keys = True) # Fall back to the slow way!
{'fraction_non_alphanumeric': 0.17027027027027028, 'fraction_numerical': 0.0018018018018018018, 'mean_word_length': 1.5658198614318706, 'pattern_counts': {'":': 2, '<': 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': '4302776', 'n_tokens_mistral': 367, 'n_tokens_neox': 359, 'n_words': 104}