Skip to main content

A delta-reduction CLI tool for minimising files

Project description

delta-reduce

A delta-reduction tool for minimising a file to the smallest version that still satisfies a given test. Similar in spirit to CReduce.

How it works

The tool repeatedly tries to delete chunks of lines from the input file. It scans from the bottom of the file upward, testing each deletion. The chunk size starts at the full file size and is reduced as the algorithm makes passes over the file. After 4 successful deletions the chunk size grows again, speeding up reduction when progress is easy. This repeats until a full pass removes nothing.

Multiple passes alternate an offset of 0 and 1 to avoid missing deletions that straddle chunk boundaries.

Installation

pip install .

Usage

delta-reduce --test <script> --input <file> [-n <threads>]
Option Description
--test SCRIPT Script that exits 0 if the candidate file is acceptable, non-zero otherwise.
--input FILE File to reduce. Overwritten in place as progress is made.
-n N Number of parallel threads (default: 4).

The original file is backed up to <file>.orig on the first run. Subsequent runs will not overwrite it.

Test script interface

The script is invoked with its working directory set to a temporary directory containing the candidate file under the original filename. Any external resources must be referenced by absolute path.

#!/bin/sh
# Example: keep reducing as long as the file still triggers a compiler error
gcc -c input.c 2>&1 | grep -q 'use of undeclared identifier'

Development

uv venv && uv pip install -e ".[dev]"
pytest

Project details


Download files

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

Source Distribution

delta_reduce-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

delta_reduce-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file delta_reduce-0.1.0.tar.gz.

File metadata

  • Download URL: delta_reduce-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}

File hashes

Hashes for delta_reduce-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4c947ef90de2bc47ce8d9fcaece0acb922484c21cc7a479ee2b5d597813a023
MD5 6c1effccd250919e2ef6e4b6890852a5
BLAKE2b-256 6d0787b72710f5eaefbe482dffc40764d0f53912ab50f0196fcc29b758d6bc38

See more details on using hashes here.

File details

Details for the file delta_reduce-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: delta_reduce-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}

File hashes

Hashes for delta_reduce-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41cf7444be2f060151f31c8b1b37ac361eb0da8097d43c8129c58741c6033518
MD5 df47096f8a62e09aebad6d2adabfe374
BLAKE2b-256 708748c1f37416795f8b6e096835e021d014682fd3aaf3ed238438e05d8523dc

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 Pingdom Monitoring Sentry Error logging StatusPage Status page