{ "info": { "author": "Alexander Marshalov", "author_email": "_@marshalov.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython" ], "description": "# opyum\n\n[![version](https://img.shields.io/pypi/v/opyum.svg)](http://pypi.python.org/pypi/opyum)\n[![downloads](https://img.shields.io/pypi/dw/opyum.svg)](http://pypi.python.org/pypi/opyum)\n[![license](https://img.shields.io/pypi/l/opyum.svg)](http://pypi.python.org/pypi/opyum)\n[![status](https://img.shields.io/pypi/status/opyum.svg)](http://pypi.python.org/pypi/opyum)\n[![pyversions](https://img.shields.io/pypi/pyversions/opyum.svg)](http://pypi.python.org/pypi/opyum)\n\n\n## Description\n\n**Optimizing Python applications without mutilation code.** \n\nUse the automatic modification of AST for code optimization, which is transparent to the user and requires the addition of only a few lines.\n\n\n## Usage\n\n**Decorator**:\n\n```python\nfrom opyum import optimize\n\n@optimize\ndef function_for_optimize():\n ...\n```\n\n**Import-hook**:\n\n```python\nimport opyum\nopyum.activate()\n\n# other imports\n```\n\n**\"With\" syntax:**\n\n```python\nimport opyum\n\nwith opyum.activate:\n # other imports\n```\n\n**Command-line mode:**\n\nShow optimized source:\n\n $ opyum show myfile.py\n\nDiff between original source and optimized source:\n\n $ opyum diff myfile.py\n\nConsole diff (with \"-c\" or \"--console\" option):\n\n![console diff example](https://raw.githubusercontent.com/Amper/opyum/master/example/screen1.png)\n\nCustom app diff (with \"--app\" option):\n\n![app diff example](https://raw.githubusercontent.com/Amper/opyum/master/example/screen2.png)\n\nBy default, html diff (without options):\n\n![app diff example](https://raw.githubusercontent.com/Amper/opyum/master/example/screen3.png)\n\n\n## List of optimizations\n\n####Constant folding\n\nBefore:\n\n```python\nx = 7 * 24 * 60 * 60\ny = [i ** 2 for i in range(10) if i % 2 == 0]\nz = sum(range(1000))\n```\n\nAfter:\n\n```python\nx = 604800\ny = [0, 4, 16, 36, 64]\nz = 499500\n```\n\n####\"'Power' to 'multiplication'\" optimization\n\nBefore:\n\n```python\nx1 = a ** (-2)\nx2 = a ** (-1)\nx3 = a ** ( 0)\nx4 = a ** ( 1)\nx5 = a ** ( 2)\n```\n\nAfter:\n\n```python\nx1 = 1 / (a * a)\nx2 = 1 / a\nx3 = 1\nx4 = a\nx5 = a * a\n```\n\n####\"'Yield' to 'yield from'\" optimization\n\nBefore:\n\n```python\nfor x in some_expression:\n yield x\n```\n\nAfter\n\n```python\nyield from some_expression\n```\n\n####Builtin constant propagation\n\nBefore:\n\n```python\nfrom math import pi\ndef circumference(r):\n return 2 * pi * r\n```\n\nAfter:\n\n```python\nfrom math import pi\ndef circumference(r):\n return 2 * 3.141592653589793 * r\n```\n\n####Custom constant propagation\n\nBefore:\n\n```python\nC_PI = 3.141592653589793\n\ndef circumference(r):\n return 2 * C_PI * r\n```\n\nAfter:\n\n```python\nC_PI = 3.141592653589793\n\ndef circumference(r):\n return 2 * 3.141592653589793 * r\n```\n\n####Dead code elimination\n\nBefore:\n\n```python\ndef do_something():\n return 1\n print('returning 1')\n\nif condition1:\n pass\nelif condition2:\n do_something()\nelse:\n pass\n```\n\nAfter:\n\n```python\ndef do_something():\n return 1\n\nif not condition1 and condition2:\n do_something()\n```\n\n\n## Installation\n\nInstallation is simple with pip:\n\n $ pip install opyum\n\nor with setuptools:\n\n $ easy_install opyum\n\n\n## Documentation\n\n [opyum.readthedocs.org](http://opyum.readthedocs.org/)\n\n [opyum.rtfd.org](http://opyum.rtfd.org/)", "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/Amper/opyum", "keywords": null, "license": "BSD 3-Clause License", "maintainer": null, "maintainer_email": null, "name": "opyum", "package_url": "https://pypi.org/project/opyum/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/opyum/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Amper/opyum" }, "release_url": "https://pypi.org/project/opyum/0.2/", "requires_dist": null, "requires_python": null, "summary": "Optimizing Python applications without mutilation code", "version": "0.2" }, "last_serial": 2026337, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5b97766fdec0f4d3f4ae86bec8158cdd", "sha256": "3094f288c17843ffdf24de33410b44685c54da3df6ddde25e483a8c9877b6ff3" }, "downloads": -1, "filename": "opyum-0.1.tar.gz", "has_sig": false, "md5_digest": "5b97766fdec0f4d3f4ae86bec8158cdd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16346, "upload_time": "2016-01-24T16:43:00", "url": "https://files.pythonhosted.org/packages/f6/ad/5097650253f4d9c510052e4d05b4a4da3cbd8ad8f0e151050edfea3ca690/opyum-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "20886fb9e9c452852f3e6dba68e0f4d5", "sha256": "706b3c38f68a6ff275e76f76c1fb7c2c25c132766c49d8216880b6261ed95a0d" }, "downloads": -1, "filename": "opyum-0.2.tar.gz", "has_sig": false, "md5_digest": "20886fb9e9c452852f3e6dba68e0f4d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20512, "upload_time": "2016-03-25T05:57:14", "url": "https://files.pythonhosted.org/packages/76/a1/e3efd5bb4d3cc7c0eaff309c62b8a5dc88de68b1fb5de37f305c02a04892/opyum-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "20886fb9e9c452852f3e6dba68e0f4d5", "sha256": "706b3c38f68a6ff275e76f76c1fb7c2c25c132766c49d8216880b6261ed95a0d" }, "downloads": -1, "filename": "opyum-0.2.tar.gz", "has_sig": false, "md5_digest": "20886fb9e9c452852f3e6dba68e0f4d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20512, "upload_time": "2016-03-25T05:57:14", "url": "https://files.pythonhosted.org/packages/76/a1/e3efd5bb4d3cc7c0eaff309c62b8a5dc88de68b1fb5de37f305c02a04892/opyum-0.2.tar.gz" } ] }