xopen
Open compressed files transparently
Decision gist · record as of 2026-08-14
Yes. xopen is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. It solves a genuine problem—transparent compressed file handling—with a minimal, stable API. The optional backends (isal, zlib-ng, backports.zstd) gracefully degrade if unavailable, so the package works out of the box. Suitable for any workflow involving compressed files.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Zstandard support requires either the zstd command-line tool, backports.zstd package, or Python 3.14+ standard library compression.zstd module.
- Low install friction with a pure-Python wheel.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions—you may use, modify, and distribute xopen freely provided you include the license notice.
last release 2026-06-03 (72 days) · last repo commit 2026-06-05 · 81 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 822,444 downloads/mo, #4,972 on PyPI
Alternatives
Verify before relying
from xopen import xopen
# Read a gzip file
with xopen("file.txt.gz") as f:
content = f.read()
# Write with compression level and threading control
with xopen("file.txt.xz", mode="wb", threads=0, compresslevel=3) as f:
f.write(b"Hello")- Performance characteristics compared to direct use of individual compression libraries for specific formats.
- Behavior when optional backends (isal, zlib-ng, backports.zstd) are not installed—exact fallback chain and performance impact.
What it is and what it does
xopen is a file-opening utility that extends Python's built-in open() function to handle compressed files transparently. When you pass a filename with a recognized compression extension (.gz, .bz2, .xz, .zst), xopen automatically detects the format and opens it with an appropriate decompressor. For writing, the format is inferred from the filename extension; for reading, it can detect format from either the extension or the file's magic bytes. The package intelligently delegates to the most efficient available backend—preferring specialized libraries like python-isal and python-zlib-ng for gzip, external tools like pigz and xz for parallel compression, and falling back to Python's standard library (gzip, lzma, bz2) when specialized backends are unavailable.
The API is intentionally minimal: a single xopen() function that accepts the same parameters as built-in open() plus compression-specific options like compresslevel and threads. By default, xopen spawns additional threads (up to four) to offload compression work from the main Python thread, though this can be disabled by setting threads=0. The package also ensures reproducible gzip output by stripping timestamps from headers. It's designed for workflows that need to read or write compressed files without coupling to a specific compression library or worrying about which backend is available.
Use it for
- Processing large compressed log files or data archives without decompressing to disk first.
- Writing compressed output in a script without manually choosing and configuring a compression backend.
- Reading files where compression format is unknown, relying on magic-byte detection.
- Parallel compression/decompression of large files by leveraging multi-threaded backends.
- Reproducible data pipelines that generate gzip files with consistent output across runs.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
xopen is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. It solves a genuine problem—transparent compressed file handling—with a minimal, stable API. The optional backends (isal, zlib-ng, backports.zstd) gracefully degrade if unavailable, so the package works out of the box. Suitable for any workflow involving compressed files.
Install
xopen on PyPI
Before you install
Low install friction with a pure-Python wheel. Three optional compression backends (isal, zlib-ng, backports.zstd) are listed as runtime dependencies but the package gracefully falls back to Python built-ins if unavailable. Active maintenance with a recent release (72 days old).
Requires Python 3.10 or later. Zstandard support requires either the zstd command-line tool, backports.zstd package, or Python 3.14+ standard library compression.zstd module.
License in practice
MIT license permits commercial and private use with minimal restrictions—you may use, modify, and distribute xopen freely provided you include the license notice.
Quickstart
from xopen import xopen
# Read a gzip file
with xopen("file.txt.gz") as f:
content = f.read()
# Write with compression level and threading control
with xopen("file.txt.xz", mode="wb", threads=0, compresslevel=3) as f:
f.write(b"Hello")
Verify before relying
- Performance characteristics compared to direct use of individual compression libraries for specific formats.
- Behavior when optional backends (isal, zlib-ng, backports.zstd) are not installed—exact fallback chain and performance impact.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesisalzlib-ngbackports.zstd |
| Maintenance | Actively maintained 72 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 822,444 / month, #4,972 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableProgramming Language :: Python :: 3 |
Evidence: xopen-2.1.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “transparent compressed file reading”
- xopenxopen provides a drop-in replacement for Python's built-in open()…
- pylibjpegDecodes and encodes JPEG, JPEG-LS, JPEG 2000, and RLE image formats,…
- indexed-gzipProvides fast random access to gzip-compressed files by building an…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also bz2file · compress-pickle · pyzstd · indexed-gzip · dnaio · zipfile-zstd · pgzip · smart-open · mgzip · zstd