[issue26379] zlib decompress as_bytearray flag

Joe Jevnik report at bugs.python.org
Thu Feb 18 14:51:31 EST 2016


Joe Jevnik added the comment:

The recipe you showed looks like it is very complicated for the expected use case of decompressing all of the data into a mutable buffer. One difference I see with this and struct.pack_into or socket.recv_into is that in both of those cases we know how large our buffer needs to be. With zlib.decompress there is not a simple way for users to preallocate a buffer to hold the result and need to resort to some looping with a lot of resizes. I think that returning either a mutable or immutable buffer hits 95% of use cases. If we go with the decompress_into method I would strongly advise putting decompress_as_bytearray into the standard library so that users do not need write this themselves.

Thank you for pointing me at the bz2 and LZMA modules. When we come to an agreement on the API I will update bz2 and LZMA so that they match. Should I also update the gzip module?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26379>
_______________________________________


More information about the Python-bugs-list mailing list