mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
![]() Previously, the _BlocksOutputBuffer code creates a list of bytes objects to handle the output data from compression libraries. This ends up being slow due to the output buffer code needing to copy each bytes element of the list into the final bytes object buffer at the end of compression. The new PyBytesWriter API introduced in PEP 782 is an ergonomic and fast method of writing data into a buffer that will later turn into a bytes object. Benchmarks show that using the PyBytesWriter API is 10-30% faster for decompression across a variety of settings. The performance gains are greatest when the decompressor is very performant, such as for Zstandard (and likely zlib-ng). Otherwise the decompressor can bottleneck decompression and the gains are more modest, but still sizable (e.g. 10% faster for zlib)! Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> |
||
---|---|---|
.. | ||
clinic | ||
_zstdmodule.c | ||
_zstdmodule.h | ||
buffer.h | ||
compressor.c | ||
decompressor.c | ||
zstddict.c | ||
zstddict.h |