{ "info": { "author": "Gareth Rees", "author_email": "gdr@garethrees.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python :: 2", "Topic :: Software Development :: Pre-processors" ], "description": "======\nminipy\n======\na Python 2 minifier\nby Gareth Rees \n\n\nIntroduction\n------------\n**minipy** is a minifier for Python 2. It rewrites Python 2 source code in a\nway that preserves the meaning of the code while reducing it in\nsize. For example::\n\n $ cat fib.py\n cache = {0: 0, 1: 1, 2: 1, 3: 2}\n def fibonacci(n):\n \"\"\"Return the nth Fibonacci number.\"\"\"\n if n not in cache:\n a = n // 2\n r = n % 2\n m = (r * 2) - 1\n cache[n] = fibonacci(a + 1) ** 2 + m * fibonacci(a + r - 1) ** 2\n return cache[n]\n\n $ minipy --rename --docstrings fib.py\n b={0:0,1:1,2:1,3:2}\n def c(a):\n if a not in b:d=a//2;e=a%2;f=e*2-1;b[a]=c(d+1)**2+f*c(d+e-1)**2\n return b[a]\n\n\nCommand line\n------------\n::\n\n Usage: minipy [options] [-o OUTPUT] FILE\n\n Options:\n --version show program's version number and exit\n -h, --help show this help message and exit\n -o OUTPUT, --output=OUTPUT\n output file (default: stdout)\n -D, --docstrings remove docstrings and other statements with no side\n effects (implies --noselftest)\n -R, --rename aggressively rename non-preserved variables\n -i INDENT, --indent=INDENT\n number of spaces per indentation level\n -p PRESERVE, --preserve=PRESERVE\n preserve words from renaming (separate by commas)\n --nojoinlines put each statement on its own line\n --noselftest skip the self-test\n --debug dump the parse tree\n\n\nThe self-test\n-------------\nGenerating minified source code without accidentally changing the\nmeaning is tricky: see the `list of issues`_ for many awkward cases\nthat had to be fixed. Therefore, in its default operating mode, minipy\nperforms a \u201cself-test\u201d: it takes the minified code, re-parses it, and\nasserts that the parse tree for the minified code is identical to the\nparse tree for the original code. If the self-test passes, then you can\nbe highly confident that minipy has not changed the meaning of your\ncode.\n\nIn order to pass the self-test, minipy must eschew a few changes to the\ncode that result in harmless changes to the parse tree. These changes\nare:\n\n* Replacing ``pass`` with ``0``.\n* Replacing ``-(1)`` with ``-1``.\n\nYou can use the ``--noselftest`` option to enable these changes, but by\ndisabling the self-test you accept a small risk of a bug in minipy\nchanging the meaning of your code.\n\nThe optional transformations ``--rename`` and ``--docstrings`` can\u2019t be\ncombined with the self-test, so these options imply ``--noselftest``.\n\nPlease report_ all self-test failures, attaching the code that causes\nthe failure.\n\n\nRenaming\n--------\nPython\u2019s use of introspection and duck typing means that it is not\npossible to change names in a program without risk of changing the\nmeaning. The ``--rename`` option to minipy therefore makes a \u201cbest attempt\u201d\nto discover names that need to be preserved, but does not guarantee\nanything. Use at your own risk!\n\nThe following names are preserved when renaming:\n\n* Names specified on the command-line via the ``--preserve`` option\n (write ``--preserve=name1,name2,name3`` to preserve more than one name).\n* Built-in names (``abs``, ``all``, ``any``, ``apply``, ...).\n* Any name used as an attribute (``.join``, ``.index``, ``.copy``, ``.sort``, ...).\n* Any name starting and ending with two underscores.\n* The names of all imported modules.\n* Any name exported by a module in a ``from module import *`` statement.\n* Any name in the list assigned to the ``__all__`` global variable.\n\n\nLicense\n-------\nminipy is free software: you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation, either version 3 of the License, or (at your\noption) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the `GNU\nGeneral Public License`_ for more details.\n\n\n.. _list of issues: https://github.com/gareth-rees/minipy/issues?state=closed\n.. _report: https://github.com/gareth-rees/minipy/issues/new\n.. _GNU General Public License: http://www.gnu.org/copyleft/gpl.html", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gareth-rees/minipy", "keywords": null, "license": "GNU General Public License (GPL) Version 3", "maintainer": null, "maintainer_email": null, "name": "minipy", "package_url": "https://pypi.org/project/minipy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/minipy/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/gareth-rees/minipy" }, "release_url": "https://pypi.org/project/minipy/0.2/", "requires_dist": null, "requires_python": null, "summary": "Minify Python 2 source code", "version": "0.2" }, "last_serial": 738584, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "004b688c141d869d64d14fca18b74cac", "sha256": "de2f77bbb9d588787b1e190629cee914d23792d8f97d11b482c29bcc57181a9f" }, "downloads": -1, "filename": "minipy-0.1.tar.gz", "has_sig": false, "md5_digest": "004b688c141d869d64d14fca18b74cac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12683, "upload_time": "2011-08-06T16:26:06", "url": "https://files.pythonhosted.org/packages/c4/18/31c045c8c6879f6aebcb0af10fc06aaf156926ad595cde512c54e90a4fd7/minipy-0.1.tar.gz" } ], "0.2": [] }, "urls": [] }