ncompress
LZW compression and decompression
What it is and what it does
ncompress is a Python binding to LZW compression, ported from the classic (N)compress CLI tool. It exposes two main functions—compress() and decompress()—that work with either raw bytes or BytesIO objects, returning compressed or decompressed data respectively. The library is implemented in C++ with Python bindings, offering a direct port of the original compress algorithm with minimal changes.
The package has no runtime dependencies and ships as pre-compiled wheels for Python 3.8+ across macOS, Linux, and Windows on multiple architectures. It's designed for straightforward use: pass data in, get compressed or decompressed output back. The BytesIO variants are slightly faster because they avoid an intermediate copy during bytes-to-string conversion.
Use it for:
- Compress or decompress data using the classic LZW algorithm when compatibility with (N)compress format is needed.
- Integrate LZW compression into Python applications without external CLI tool dependencies.
- Process large BytesIO streams with minimal memory overhead by using the BytesIO-based compress/decompress functions.
- Archive or transmit data using a well-established, lossless compression format.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides LZW compression and decompression functions that accept bytes or BytesIO objects and return compressed or decompressed data.
Yes, if you need LZW compression specifically or must work with (N)compress-compatible data. The permissive license, zero runtime dependencies, and broad platform support make it low-friction to add. However, maintenance is dormant (last release 927 days ago), so consider whether you need active support or would prefer a more actively maintained compression library for general-purpose use.
Install
ncompress on PyPI
pip
pip install ncompressuv
uv add ncompresspoetry
poetry add ncompressInstalling ncompress
Before you install
Medium install friction due to compiled wheels; however, wheels are pre-built for Python 3.8+ across all major platforms and architectures, making installation straightforward. Maintenance is dormant—last release was 927 days ago, though the repository remains active.
License in practice
Released under the Unlicense (public domain dedication) with permissive treatment, meaning you can use, modify, and distribute it freely with no restrictions. A small portion (BytesIO wrapper) is adapted from cctbx under the Lawrence Berkeley National Labs BSD variant license; see the source file for details.
Quickstart
pip install ncompress
from ncompress import compress, decompress
original = b'hello world'
compressed = compress(original)
decompressed = decompress(compressed)
Requires Python 3.8 or later.
Verify before relying
- Performance characteristics compared to other LZW or general-purpose compression libraries in typical use cases.
- Whether the 15% speed advantage of BytesIO-based functions over bytes conversion is significant for your data sizes.
Package facts
| License | This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 927 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 177,236/month — #10,218 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ncompress-1.0.2-cp310-cp310-macosx_10_14_universal2.whl; ncompress-1.0.2-cp310-cp310-macosx_10_14_x86_64.whl; ncompress-1.0.2-cp310-cp310-macosx_11_0_arm64.whl; ncompress-1.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; ncompress-1.0.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; ncompress-1.0.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; ncompress-1.0.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl; ncompress-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ncompress-1.0.2-cp310-cp310-musllinux_1_1_aarch64.whl; ncompress-1.0.2-cp310-cp310-musllinux_1_1_i686.whl; ncompress-1.0.2-cp310-cp310-musllinux_1_1_ppc64le.whl; ncompress-1.0.2-cp310-cp310-musllinux_1_1_s390x.whl; ncompress-1.0.2-cp310-cp310-musllinux_1_1_x86_64.whl; ncompress-1.0.2-cp310-cp310-win32.whl; ncompress-1.0.2-cp310-cp310-win_amd64.whl; ncompress-1.0.2-cp310-cp310-win_arm64.whl; ncompress-1.0.2-cp311-cp311-macosx_10_14_universal2.whl; ncompress-1.0.2-cp311-cp311-macosx_10_14_x86_64.whl; ncompress-1.0.2-cp311-cp311-macosx_11_0_arm64.whl; ncompress-1.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Keywords: LZW, compression
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
python-neo-lzfProvides fast compression and decompression of…
permissive · top 15,000 on PyPI
unlzw3Decompresses .Z files (Unix compress format)…
permissive · top 15,000 on PyPI
pcodecPcodec compresses and decompresses numerical…
unclear · top 15,000 on PyPI
xpress9Xpress9 is a Python wrapper for Microsoft's…
permissive · top 15,000 on PyPI
lzstringCompresses and decompresses text using the…
permissive · top 15,000 on PyPI
compressed-rtfCompresses and decompresses Rich Text Format…
permissive · top 5,000 on PyPI
pynwbPyNWB provides a high-level Python API for…
permissive · top 15,000 on PyPI
python-lzfProvides Python bindings to the liblzf…
permissive · top 15,000 on PyPI
lzfsePython bindings for the LZFSE reference…
permissive · top 5,000 on PyPI
lzallrightlzallright provides Python bindings to compress…
permissive · top 15,000 on PyPI