• Kirill Smelkov's avatar
    strconv: Optimize quoting lightly · a11cb5dc
    Kirill Smelkov authored
    Add type annotations and use C-level objects instead of py-ones where it
    is easy to do. We are not all-good yet, but this already brings some noticable speedup:
    
        name                 old time/op  new time/op  delta
        quote[a]              786µs ± 1%    10µs ± 0%  -98.76%  (p=0.016 n=4+5)
        quote[\u03b1]        1.12ms ± 0%  0.41ms ± 0%  -63.37%  (p=0.008 n=5+5)
        quote[\u65e5]         738µs ± 2%   258µs ± 0%  -65.07%  (p=0.016 n=4+5)
        quote[\U0001f64f]     920µs ± 1%    78µs ± 0%  -91.46%  (p=0.016 n=5+4)
        stdquote             1.19µs ± 0%  1.19µs ± 0%     ~     (p=0.794 n=5+5)
        unquote[a]           1.08ms ± 0%  1.08ms ± 1%     ~     (p=0.548 n=5+5)
        unquote[\u03b1]       797µs ± 0%   807µs ± 1%   +1.23%  (p=0.008 n=5+5)
        unquote[\u65e5]       522µs ± 0%   520µs ± 1%     ~     (p=0.056 n=5+5)
        unquote[\U0001f64f]  3.21ms ± 0%  3.14ms ± 0%   -2.13%  (p=0.008 n=5+5)
        stdunquote            815ns ± 0%   836ns ± 0%   +2.63%  (p=0.008 n=5+5)
    a11cb5dc
_golang_str.pyx 76.1 KB