Skip to main content

kompress lets you transparently decompress common archive formats while using pathlib.Path objects.

It attempts to keep the API as close to pathlib, but things may not be perfect yet

The common case for this is:

  • You have a compressed file that when decompressed contains some text
  • You have a function (perhaps from another library, that you don't control), that knows how to take a pathlib.Path object and call .read() or .read_text() on it

Without wrapping the function or adding logic to let it read from compressed files, this lets you do the following:

from pathlib import Path
from kompress import CPath, is_compressed

def char_count(path: Path) -> int:
    # here, if a CPath is passed, it decompresses and returns a string
    return len(path.read_text())

inp = input("Enter a file to process: ")  # file came from user
char_count(CPath(inp))

This currently supports these archive formats:

  • .xz
  • .zip
  • .zst
  • .tar.gz
  • .gz
  • .zstd (since python3.14, on older version use pip install 'kompress[zstd]')
  • .lz4 (pip install 'kompress[lz4]')

If it doesn't recognize the filetype, it will just call pathlib.Path.open, reading it like a regular file.

Originally discussed in this HPI issue

Installing

pip install kompress

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kompress-0.3.20260707.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kompress-0.3.20260707-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file kompress-0.3.20260707.tar.gz.

File metadata

  • Download URL: kompress-0.3.20260707.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kompress-0.3.20260707.tar.gz
Algorithm Hash digest
SHA256 c7896945d671077cfb0e26b5e85b3d0e1680c1cdeacc42b0f23b329f17656e34
MD5 5519bbdd5972359cf751fcb274eb6612
BLAKE2b-256 418759d716766236887d24b46f846914e4237d41848965aa48f6f40c786f6707

See more details on using hashes here.

File details

Details for the file kompress-0.3.20260707-py3-none-any.whl.

File metadata

  • Download URL: kompress-0.3.20260707-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kompress-0.3.20260707-py3-none-any.whl
Algorithm Hash digest
SHA256 48a5446ab36335660fa54f24980cfefe3681cdbf750dfdd6cca8e815657f1c27
MD5 bfdd8ce2618c5663fae49aadd0b6032b
BLAKE2b-256 951df381e7b4c25adae4ecceee77f4a4f0a31ad5726c808f764cd45b938afa94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page