Skip to main content

liquify

the Python 2 minifier behind liquen almost totally based on minipy by Gareth Rees <http://garethrees.org/>

Introduction

liquify is a minifier for Python 2 focused on maintaining usability of the minified code as an imported module (which means it preserves functions and variables that could have been of use for external code calling the minified code). For example:

$ cat fib.py
cache = {0: 0, 1: 1, 2: 1, 3: 2}
def fibonacci(n):
    """Return the nth Fibonacci number."""
    if n not in cache:
        a = n // 2
        r = n % 2
        m = (r * 2) - 1
        cache[n] = fibonacci(a + 1) ** 2 + m * fibonacci(a + r - 1) ** 2
    return cache[n]

$ liquify --module --docstrings fib.py
cache={0:0,1:1,2:1,3:2}
def fibonnacci(a):
 if a not in b:d=a//2;e=a%2;f=e*2-1;b[a]=fibonnacci(d+1)**2+f*c(d+e-1)**2
 return b[a]

Command line

Usage: liquify [options] [-o OUTPUT] FILE

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -o OUTPUT, --output=OUTPUT
                        output file (default: stdout)
  -D, --docstrings      remove docstrings and other statements with no side
                        effects (implies --noselftest)
  -R, --rename          aggressively rename non-preserved variables
  -i INDENT, --indent=INDENT
                        number of spaces per indentation level
  -p PRESERVE, --preserve=PRESERVE
                        preserve words from renaming (separate by commas)
  -m, --module          preserve top level object names (for use as imported

  --nojoinlines         put each statement on its own line
  --noselftest          skip the self-test
  --debug               dump the parse tree

License

liquify is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Metadata

Release files for liquify 0.3

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

Source distribution (sdist)

Source distribution for liquify 0.3
File Size Uploaded
liquify-0.3.tar.gz 14.8 kB Details

Release files / liquify-0.3.tar.gz

Download URL liquify-0.3.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d52d8f48d68c5d9f1ba8decd6d4611f68618a486278835a877da262ec70a49e5
BLAKE2b-256 checksum
How to use checksums
609c798963e6d5ebcb831718a2cb304ce4c782f1081045c641cf42d984b5ad0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file

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