{"id":27687,"library":"deflate","title":"deflate","description":"Python wrapper for libdeflate, providing fast compression and decompression for raw deflate, zlib, and gzip formats. Current version: 0.8.1. Release cadence: irregular, with recent updates focusing on CMake/scikit-build-core migration.","status":"active","version":"0.8.1","language":"python","source_language":"en","source_url":"https://github.com/dcwatson/deflate","tags":["compression","deflate","zlib","gzip","libdeflate"],"install":[{"cmd":"pip install deflate","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Direct import of module does not expose Deflate class at top level.","wrong":"import deflate","symbol":"Deflate","correct":"from deflate import Deflate"},{"note":"","wrong":"","symbol":"DEFLATE","correct":"from deflate import DEFLATE"}],"quickstart":{"code":"from deflate import Deflate\n\ndata = b'Hello, world! ' * 1000\ncompressed = Deflate.compress(data, format='deflate')\ndecompressed = Deflate.decompress(compressed, format='deflate')\nassert data == decompressed\nprint('Success!')","lang":"python","description":"Demonstrates basic compression and decompression using the Deflate class."},"warnings":[{"fix":"Replace `except DeflateError` with `except ValueError`.","message":"In version 0.7.0, DeflateError was removed; invalid gzip data now raises ValueError instead of DeflateError. If your code catches DeflateError, it will break.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Use level=6 for default compression, or any level 1-12 for libdeflate (12 is maximum).","message":"Compression level 0 means no compression, not default. Level 6 is the default. If you pass level=0 expecting 'fastest', you get uncompressed data.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `deflate.deflate(data)` with `Deflate.compress(data, format='deflate')`.","message":"The function `deflate.deflate` and `deflate.inflate` are deprecated since 0.7.0. Use the Deflate class instead.","severity":"deprecated","affected_versions":">=0.7.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from deflate import Deflate` (this works in 0.7+). If you have an old version, upgrade to 0.8.1.","cause":"Importing `import deflate` then using `deflate.Deflate` works, but older code may mistakenly try `from deflate import Deflate` after upgrading from version <0.7 where symbols were different.","error":"AttributeError: module 'deflate' has no attribute 'Deflate'"},{"fix":"Ensure data is actually gzip-compressed, or catch ValueError.","cause":"Data is not valid gzip. The library raises ValueError (since 0.7.0) instead of the old DeflateError.","error":"ValueError: Invalid header for gzip format"},{"fix":"Upgrade to 0.8.1 and change exception handling to ValueError.","cause":"Using an older version (<0.7.0) where DeflateError existed. Upgrading to 0.7+ removes this exception.","error":"deflate.DeflateError: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}