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

Metadata

Release files for kompress 0.3.20260707

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kompress 0.3.20260707
File Size Uploaded Provenance Actions
kompress-0.3.20260707.tar.gz 22.3 kB Without provenance Details for kompress-0.3.20260707.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kompress 0.3.20260707
File Interpreter ABI Platform Actions
kompress-0.3.20260707-py3-none-any.whl Python 3 none any Details for kompress-0.3.20260707-py3-none-any.whl

Total release size: 41.1 kB

Release files / kompress-0.3.20260707.tar.gz

Download URL kompress-0.3.20260707.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c7896945d671077cfb0e26b5e85b3d0e1680c1cdeacc42b0f23b329f17656e34
BLAKE2b-256 checksum
How to use checksums
418759d716766236887d24b46f846914e4237d41848965aa48f6f40c786f6707
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / kompress-0.3.20260707-py3-none-any.whl

Download URL kompress-0.3.20260707-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48a5446ab36335660fa54f24980cfefe3681cdbf750dfdd6cca8e815657f1c27
BLAKE2b-256 checksum
How to use checksums
951df381e7b4c25adae4ecceee77f4a4f0a31ad5726c808f764cd45b938afa94
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for kompress 0.3.20260707

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page