Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Minify Python 2 modules

Project description

the Python 2 minifier behind liquen almost totally based on minipy by Gareth Rees <>


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
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
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

  --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


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.

Project details

Release history Release notifications

This version
History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
liquify-0.3.tar.gz (14.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page