[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

Serhiy Storchaka report at bugs.python.org
Tue Mar 17 19:41:39 CET 2015


Serhiy Storchaka added the comment:

You patch is correct Wolfgang, but with cast('B') the patch would be smaller (no need to replace len(data) to nbytes).

While we are here, it is possible to add the support of general byte-like objects.

if not isinstance(data, bytes):
    data = memoryview(data).cast('B')

isinstance() check is just for optimization, it can be omitted if doesn't affect a performance.

----------

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


More information about the Python-bugs-list mailing list