Minify Python 2 modules
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file liquify-0.3.tar.gz
.
File metadata
- Download URL: liquify-0.3.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52d8f48d68c5d9f1ba8decd6d4611f68618a486278835a877da262ec70a49e5 |
|
MD5 | 6b3300677007ee5fbc5def367ebc3eb5 |
|
BLAKE2b-256 | 609c798963e6d5ebcb831718a2cb304ce4c782f1081045c641cf42d984b5ad0c |