]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119182: Use public PyUnicodeWriter API in union_repr() (#120797)
authorVictor Stinner <vstinner@python.org>
Thu, 20 Jun 2024 18:39:34 +0000 (20:39 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Jun 2024 18:39:34 +0000 (20:39 +0200)
commitc1553bc34a537e00d6513da7df1c427df3570574
tree4c4d861f3feb9a5007f67b34484f8903359f3e7b
parent73b4492c19f494c1b10dfa0b80840a52ce3c63a2
gh-119182: Use public PyUnicodeWriter API in union_repr() (#120797)

The public PyUnicodeWriter API enables overallocation by default and
so is more efficient.

Benchmark:

python -m pyperf timeit \
    -s 't = int | float | complex | str | bytes | bytearray' \
       ' | memoryview | list | dict' \
    'str(t)'

Result:

1.29 us +- 0.02 us -> 1.00 us +- 0.02 us: 1.29x faster
Objects/unionobject.c