Skip to main content

yez — maximum-ratio lossless compression

YEz is a from-scratch, multi-stage lossless compressor (C++17 core, Python API). It combines match parsing with a hash-chain/optimal parser, bitwise context mixing with 12 context models, x86/ARM64/delta filters, and a CRC32-verified container. No external compression library is used anywhere — pip install yez compiles the core from source on your machine.

Every archive is lossless and verified: the original data's CRC32 is stored and decompress() never returns anything that does not match byte-for-byte.

Developed by Ahmed Alhrrani — t.me/maho_s9.

Install

pip install yez

The package needs a C++17 compiler at install time; it picks the first available of c++, g++, clang++ (or $CXX if set). No prebuilt binaries are downloaded — the core is always compiled from the bundled sources:

# no system compiler? the ziglang pip package works too:
pip install ziglang
CXX="python -m ziglang c++" pip install yez

Quick start

import yez

z = yez.compress(b"hello " * 100000, level=9)   # -> bytes (a .yez archive)
data = yez.decompress(z)                         # -> exact original bytes

yez.compress_file("big.csv", "big.csv.yez", level=7)
yez.decompress_file("big.csv.yez", "big.csv")

info = yez.inspect(z)     # dict: version, mode, level, sizes, crc, blocks[]
ok = yez.check(z)         # structural validation without decompressing
yez.is_yez(z)             # magic-byte test

Measured results

Mixed 6.3 MB corpus of real files (text, CSV, JSON, XML, HTML), compared with Python's stdlib codecs on the same machine:

Codec Total bytes % of original vs lzma -9e
gzip -9 1,115,692 17.7% +62%
bzip2 -9 760,867 12.1% +11%
lzma -9e (xz) 688,240 10.9% —
yez level 1 928,199 14.8% +35% (−17% vs gzip -9)
yez level 5 696,144 11.1% +1%
yez level 9 447,126 7.1% −35%

Per-file highlights (level 9 vs lzma -9e): text −25%, CSV −52%, JSON −28%, XML −38%, HTML −21%.

Levels

Level Mode What runs Use for
1–3 Fast greedy/lazy/optimal match parsing speed, still beats gzip -9
4–6 Balanced optimal parsing + per-block tuning everyday default (≈ xz -9e)
7–9 Maximum parsing + bitwise context mixing (12 models) archival, maximum ratio

Level 9 is slow by design (context mixing is symmetric: decompression does the same modelling work, ≈0.1–0.2 MB/s each way). Level 5 decompresses at ~30 MB/s.

API reference

yez.compress(data, level=5, *, threads=None, block_size=0, block_crc=False) -> bytes
yez.decompress(data, *, threads=None) -> bytes
yez.compress_file(src, dst=None, level=5, *, threads=None, block_size=0, block_crc=False) -> int
yez.decompress_file(src, dst=None, *, threads=None) -> int
yez.inspect(data) -> dict
yez.check(data) -> bool
yez.is_yez(data) -> bool
yez.YezError                    # raised on corruption / bad input
yez.MAGIC                      # b"YEz"
yez.__version__
  • Accepts bytes, bytearray and memoryview.
  • threads=None picks automatically: all cores for levels 1–6, capped to 3 concurrent blocks for 7–9 (each context-mixing block holds ~400 MB of model state — the cap bounds peak memory; pass an explicit number to override).
  • block_size (bytes; 0 = level default 4/16/32 MiB) and block_crc=True (per-block CRC32 — pinpoints which block is damaged) are available for tuning.
  • Calls release the GIL, so one worker per thread scales from Python.
  • yez.YezError is raised for bad magic, unsupported version, truncation, trailing data, header checksum mismatch or payload corruption — corrupt archives never yield wrong output silently.

Command line

yez c [-c N] [-t N] [-x] input output.yez    compress
yez d [-t N] input.yez output                decompress
yez t input.yez                              test integrity
yez i input.yez                              archive information

The same interface works as python -m yez ….

How it works

Input is split into blocks; each block is analysed (constancy, entropy, text-likeness, record stride, x86/ARM64 filter scores), candidate transforms are ranked with a cheap proxy parse, then the block is encoded with the best of: raw / constant / repstream (match parsing with a context-modelled binary range coder: greedy, lazy or price-optimal parsing, per-block lc/pb tuning) / ctxmix (bitwise context mixing: 12 hashed context models — orders 1–7, a UTF-8 aware word model, sparse, record-stride and an indirect model — two gated mixers and two APM/SSE stages). The smallest actual output wins; incompressible data never expands by more than ~25 bytes.

The binding is plain ctypes over a C ABI (yez_compress, yez_decompress, yez_check, yez_inspect_json, yez_free, yez_last_error), so the same core is usable from any FFI.

License

MIT — see LICENSE. Developed by Ahmed Alhrrani (t.me/maho_s9).

Metadata

Release files for yez 1.2.0

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

Source distribution (sdist)

Source distribution for yez 1.2.0
File Size Uploaded Provenance Actions
yez-1.2.0.tar.gz 39.2 kB Without provenance Details for yez-1.2.0.tar.gz

Release files / yez-1.2.0.tar.gz

Download URL yez-1.2.0.tar.gz
Size 39.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fa99d0d293d9d54830ec583b6efdb04fa882d590c6b977c4ab674bda617de43f
BLAKE2b-256 checksum
How to use checksums
1624ab54d3c2c398e8315ead6af5051237abbea42ee8731744f3f509c91ac8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for yez 1.2.0

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.

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file No provenance

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