jcrist · GitHub

@jcrist

This significantly speeds up JSON string decoding. Using some ideas
borrowed from yyjson, as well as some general performance tricks, we:
- Use a new lookup table for determining interesting char values that
require special handling.
- Have separate processing loops for ascii and unicode
- Split off the (less common) escape handling routine into a separate
function.
- Manually unroll the string processing loops
- Apply an inline asm hack to get GCC to generate better code
Besides a faster string parsing inner loop, this also lets us determine
if a string is all ascii characters for free. In this case, we skip
calling `PyUnicode_DecodeUTF8` and instead manually create the new
string object, further accelerating decoding.

Read the original on github.com ↗