[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?
Martin Panter
report at bugs.python.org
Wed Mar 18 05:36:55 CET 2015
Martin Panter added the comment:
I would say that the current patch looks correct enough, in that it would still get the correct lengths when a memoryview() object is passed in. The zlib module’s crc32() function and compress() method already seem to support arbitrary bytes-like objects.
But to make GzipFile.write() also accept arbitrary bytes-like objects, you probably only need to change the code calculating the length to something like:
with memoryview(data) as view:
length = view.nbytes
# Go on to call compress(data) and crc32(data)
----------
nosy: +vadmium
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23688>
_______________________________________
More information about the Python-bugs-list
mailing list