{ "info": { "author": "Zian van Wijk", "author_email": "zian@cognizon.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# IterPipe\n## Introduction\nThis is a wrapper for the iterator functions in the Python Standard Library to make it easier and more readable to chain them together into a pipeline.\n\nIt is a way to implement Martin Fowler's _Collection Pipeline_ pattern (https://martinfowler.com/articles/collection-pipeline/) with Python's standard iterator functions.\n\nTo illustrate the concept, we will perform the following sequence of steps in each example:\n\n1. Start with a `range` iterator,\n2. Then `filter` to pass only the values larger or equal to 6\n3. Then square each number from step 2, using the `map` function\n4. Then `sum` the squares from step 3\n\nHere is the code, using intermediate variables, without chaining.\n```python\ndef filter_func(x):\n # Simple function used in \"filter\" examples below\n return x >= 6\n\n\ndef squared(x):\n # Simple function to square it's input. Used in \"map\" below.\n return x * x\n\ninput = range(10)\n\nintermediate_1 = filter(filter_func, input)\n\n# Apply squared function to each value returned by intermediate_1 iterator\nintermediate_2 = map(squared, intermediate_1)\n\noutput = sum(intermediate_2)\n\nprint(\"Output without chaining: {output}\".format(output=output))\n```\n\nHere is the same code, using regular Python syntax chaining. Note that execution happens inside-out, with the last operation (sum) appearing first.\n```python\ndef filter_func(x):\n return x >= 6\n\n\ndef squared(x):\n # Simple function to square it's input. Used in \"map\" below.\n return x * x\n\ninput = range(10)\n\noutput = sum(map(squared, filter(filter_func, input)))\n\nprint(\"Output with regular Python chaining: {output}\".format(output=output))\n```\n\nAnd here is the same code again, using the `IterPipe` wrapper. Note that it reads in the same order as execution happens.\n```python\nfrom IterPipe import IterPipe\n\ndef filter_func(x):\n return x >= 6\n\n\ndef squared(x):\n # Simple function to square it's input. Used in \"map\" below.\n return x * x\n\ninput = range(10)\n\noutput = (IterPipe(input) \n .filter(filter_func)\n .map(squared)\n .sum()\n )\n\nprint(\"Output with IterPipe chaining: {output}\".format(output=output))\n``` \n\nThe IterPipe wrapper supports the following functions that operate on iterators from `builtins`, `itertools` and `functools`.\n\n+ accumulate\n+ all\n+ any\n+ chain\n+ combinations\n+ combinations_with_replacement\n+ compress\n+ cycle\n+ dict\n+ dropwhile\n+ enumerate\n+ filter\n+ filterfalse\n+ frozenset\n+ groupby\n+ islice\n+ iterator\n+ list\n+ map\n+ max\n+ min\n+ next\n+ permutations\n+ product\n+ reduce\n+ set\n+ sorted\n+ starmap\n+ sum\n+ takewhile\n+ tee\n+ tuple\n+ zip\n+ zip_longest\n\n## Installation\n\nWorks with Python 3.4 or later.\n\n```\npip install -U IterPipe\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ZianVW/IterPipe.git", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "IterPipe", "package_url": "https://pypi.org/project/IterPipe/", "platform": "", "project_url": "https://pypi.org/project/IterPipe/", "project_urls": { "Homepage": "https://github.com/ZianVW/IterPipe.git" }, "release_url": "https://pypi.org/project/IterPipe/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Iterator pipeline wrapper in the spirit of Martin Fowler's Collection Pipeline pattern", "version": "0.0.3" }, "last_serial": 4919417, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "bba5e14e81a816c6494989d7d0a13992", "sha256": "5169e493bb93e7e8de6a2e8a657ff6b654634ea4ef8ee62de1f4aa6cb74d8bef" }, "downloads": -1, "filename": "IterPipe-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "bba5e14e81a816c6494989d7d0a13992", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16695, "upload_time": "2019-03-09T17:14:25", "url": "https://files.pythonhosted.org/packages/59/80/517bc819a6e2e69a750dd3d9a4b34934208d97db88d48412e8da4a0d2552/IterPipe-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d43fc3bdf13761be0d85d6d53ef56d7f", "sha256": "ddd85be23685228515c68bf8eef2b76e94c470e72b6bd7c422df07978c5b649f" }, "downloads": -1, "filename": "IterPipe-0.0.2.tar.gz", "has_sig": false, "md5_digest": "d43fc3bdf13761be0d85d6d53ef56d7f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4023, "upload_time": "2019-03-09T17:14:27", "url": "https://files.pythonhosted.org/packages/4f/89/fb76a32955bbcaa2998870443638315ea2aff6cf8c2c952265b40a76362b/IterPipe-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e4d1a5aa63bf37411726150e62f7f94f", "sha256": "bc25fd0688ce4ca457c5723941920283104ad2b1e9c37dab8869cd67b843c5c0" }, "downloads": -1, "filename": "IterPipe-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e4d1a5aa63bf37411726150e62f7f94f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16959, "upload_time": "2019-03-09T19:27:12", "url": "https://files.pythonhosted.org/packages/f4/20/01237003d55ca34082271cb29e4dd895b6bef1b348cf55b79805ce9589b2/IterPipe-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6540da7f2866479f08f178617539731", "sha256": "d92661893381e790dc615461f2e9645e5a10e4c2a092b4a97dbfe0bc06425c11" }, "downloads": -1, "filename": "IterPipe-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a6540da7f2866479f08f178617539731", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4405, "upload_time": "2019-03-09T19:27:14", "url": "https://files.pythonhosted.org/packages/69/1f/47519508da0cc1457b15521059bd2918e639d2179563c51572bf9b702315/IterPipe-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e4d1a5aa63bf37411726150e62f7f94f", "sha256": "bc25fd0688ce4ca457c5723941920283104ad2b1e9c37dab8869cd67b843c5c0" }, "downloads": -1, "filename": "IterPipe-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e4d1a5aa63bf37411726150e62f7f94f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16959, "upload_time": "2019-03-09T19:27:12", "url": "https://files.pythonhosted.org/packages/f4/20/01237003d55ca34082271cb29e4dd895b6bef1b348cf55b79805ce9589b2/IterPipe-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6540da7f2866479f08f178617539731", "sha256": "d92661893381e790dc615461f2e9645e5a10e4c2a092b4a97dbfe0bc06425c11" }, "downloads": -1, "filename": "IterPipe-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a6540da7f2866479f08f178617539731", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4405, "upload_time": "2019-03-09T19:27:14", "url": "https://files.pythonhosted.org/packages/69/1f/47519508da0cc1457b15521059bd2918e639d2179563c51572bf9b702315/IterPipe-0.0.3.tar.gz" } ] }