[issue37587] JSON loads performance improvement for long strings

Steve Dower report at bugs.python.org
Tue Jul 30 11:18:50 EDT 2019


Steve Dower <steve.dower at python.org> added the comment:

While you're testing patches, can you try this version too?

        Py_UCS4 c = 0, minc = 0x20;
        for (next = end; next < len; next++) {
            c = PyUnicode_READ(kind, buf, next);
            if (c == '"' || c == '\\') {
                break;
            }
            minc = c < minc ? c : minc;
        }
        if (strict && minc <= 0x1f) {
            raise_errmsg("Invalid control character at", pystr, next);
            goto bail;
        }

When we tried this, the conditional expression became a "cmovl" operator which removed 3-4 branches from within the loop entirely, and it was 18% better than the baseline (which has now moved...)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37587>
_______________________________________


More information about the Python-bugs-list mailing list