<commit_before>inline bool Converter< QString >::isConvertible(PyObject* pyobj)
{
    return PyUnicode_Check(pyobj) || PyString_Check(pyobj);
}

inline PyObject* Converter< QString >::createWrapper(const QString* cppobj)
{
    return PyBaseWrapper_New(&PyQString_Type, &PyQString_Type, cppobj);
}

inline QString* Converter<QString >::copyCppObject(const QString& cppobj)
{
    return new QString(cppobj);
}

inline PyObject* Converter< QString >::toPython(const QString& cppobj)
{
    return Converter< QString >::createWrapper(new QString(cppobj));
}

inline QString Converter< QString >::toCpp(PyObject* pyobj)
{
    if (PyQChar_Check(pyobj)) {
        return QString(Converter< QChar >::toCpp(pyobj));
    } else if (PyQByteArray_Check(pyobj)) {
        return QString(Converter< QByteArray >::toCpp(pyobj));
    } else if (PyQLatin1String_Check(pyobj)) {
        return QString(Converter< QLatin1String >::toCpp(pyobj));
    } else if (PyUnicode_Check(pyobj)) {
#if defined(Py_UNICODE_WIDE)
        Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyobj);
        return QString::fromUcs4(unicode);
#else
        PyObject* str = PyUnicode_AsUTF8String(pyobj);
        QString result = QString::fromUtf8(PyString_AS_STRING(str));
        Py_DECREF(str);
        return result;
#endif
    } else if (PyString_Check(pyobj))
        return QString(Converter< char * >::toCpp(pyobj));
    return *Converter< QString* >::toCpp(pyobj);
}
<commit_msg>Speed up construction of QString's from python unicode strings.<commit_after>inline bool Converter< QString >::isConvertible(PyObject* pyobj)
{
    return PyUnicode_Check(pyobj) || PyString_Check(pyobj);
}

inline PyObject* Converter< QString >::createWrapper(const QString* cppobj)
{
    return PyBaseWrapper_New(&PyQString_Type, &PyQString_Type, cppobj);
}

inline QString* Converter<QString >::copyCppObject(const QString& cppobj)
{
    return new QString(cppobj);
}

inline PyObject* Converter< QString >::toPython(const QString& cppobj)
{
    return Converter< QString >::createWrapper(new QString(cppobj));
}

inline QString Converter< QString >::toCpp(PyObject* pyobj)
{
    if (PyQChar_Check(pyobj)) {
        return QString(Converter< QChar >::toCpp(pyobj));
    } else if (PyQByteArray_Check(pyobj)) {
        return QString(Converter< QByteArray >::toCpp(pyobj));
    } else if (PyQLatin1String_Check(pyobj)) {
        return QString(Converter< QLatin1String >::toCpp(pyobj));
    } else if (PyUnicode_Check(pyobj)) {
        Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyobj);
#if defined(Py_UNICODE_WIDE)
        return QString::fromUcs4(unicode);
#else
        return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyobj));
#endif
    } else if (PyString_Check(pyobj))
        return QString(Converter< char * >::toCpp(pyobj));
    return *Converter< QString* >::toCpp(pyobj);
}

{'fraction_non_alphanumeric': 0.12667607621736063, 'fraction_numerical': 0.0035285815102328866, 'mean_word_length': 5.031914893617022, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5982776', 'n_tokens_mistral': 944, 'n_tokens_neox': 936, 'n_words': 200}