On this page
zlib.compressobj
Prev: zlib.compress | Up: zlib | Next: zlib.crc32
Rel: zlib.adler32, zlib.compress, zlib.crc32, zlib.decompress
Ref: docs.python.org — zlib.compressobj
Tags: #public #python3 #stdlib #zlib
Import
import zlib
from zlib import compressobj
Signature & Overview
zlib.compressobj(...)
Return a compressor object.
Usage
import zlib
co = zlib.compressobj(level=6)
out = co.compress(b'chunk1 ') + co.compress(b'chunk2') + co.flush()
assert zlib.decompress(out) == b'chunk1 chunk2'
Gotchas
- Must call
.flush()at end of stream; passwbits=16 + zlib.MAX_WBITSfor gzip framing or-15for raw DEFLATE.
REPL Inspect
from zlib import compressobj
help(compressobj)
Linked from
Related notes
- tuts/python3/stdlib_module/zlib/adler32 Linked here; links to this page; shared tags: #stdlib, #zlib
- tuts/python3/stdlib_module/zlib/compress Linked here; links to this page; shared tags: #stdlib, #zlib
- tuts/python3/stdlib_module/zlib/crc32 Linked here; links to this page; shared tags: #stdlib, #zlib
- tuts/python3/stdlib_module/zlib/decompress Linked here; links to this page; shared tags: #stdlib, #zlib
- tuts/python3/stdlib_module/zlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/zlib/decompressobj links to this page; shared tags: #stdlib, #zlib
- tuts/python3/stdlib_module/zlib/error links to this page; shared tags: #stdlib, #zlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib