New submission from Ruben Vorderman <[email protected]>:
def compress(data, compresslevel=_COMPRESS_LEVEL_BEST, *, mtime=None):
"""Compress data in one shot and return the compressed string.
compresslevel sets the compression level in range of 0-9.
mtime can be used to set the modification time. The modification time is
set to the current time by default.
"""
if mtime == 0:
# Use zlib as it creates the header with 0 mtime by default.
# This is faster and with less overhead.
return zlib.compress(data, level=compresslevel, wbits=31)
header = _create_simple_gzip_header(compresslevel, mtime)
trailer = struct.pack("<LL", zlib.crc32(data), (len(data) & 0xffffffff))
# Wbits=-15 creates a raw deflate block.
return header + zlib.compress(data, wbits=-15) + trailer
^
Level should be here
I noticed this while benchmarking against python-isal. This benchmarks add
level 1 and it seemed oddly slow.
This can be fixed easily. PR coming up.
----------
components: Library (Lib)
messages: 409749
nosy: rhpvorderman
priority: normal
severity: normal
status: open
title: gzip.compress incorrectly ignores level parameter
type: behavior
versions: Python 3.11
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com