{ "info": { "author": "Evelyn-H", "author_email": "hobert.evelyn@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "[![Documentation Status](https://readthedocs.org/projects/iterchain/badge/?version=latest)](https://iterchain.readthedocs.io/en/latest/?badge=latest)\n\nIterchain: Iterator chaining for Python\n=======================================\n\nIterchain is a library intended to make manipulating iterators in Python easier and more ergonomic.\nThe design is heavily inspired by the [Rust iterator design](https://doc.rust-lang.org/std/iter/index.html), and a lot of the functionality comes from the standard Python [itertools](https://docs.python.org/3/library/itertools.html) library.\n\n\n## Why would I need this?\n\nSay we want to know the sum of all the squares of even numbers up to 100. \nHow can we do this?\n\nLet's try some straightforward, procedural Python:\n```python\n>>> total = 0\n>>> for i in range(100):\n... if i % 2 is 0:\n... total += i ** 2\n...\n>>> total\n161700\n```\n\nThis works, but if you read this for the first time it can take a bit of effort to figure out what's happening, especially in slightly less trivial cases.\nSo, how about we use iterators instead?\n\nWell, let's see:\n```python\n>>> sum(i**2 for i in range(100) if i % 2 is 0)\n161700\n```\n\nThat's pretty nice! Much shorter, and much easier to understand. \nBut there's a problem, this pattern only works for relatively simple manipulations. In those cases you could try using the python `map` and `filter` builtins (and the slightly more hidden `functools.reduce`). They let you construct more complex processing chains.\n\nLet's rewrite our iterator to use those functions instead:\n```python\n>>> sum(map(lambda x: x**2, filter(lambda x: x % 2 is 0, range(100))))\n161700\n```\n\nOkay, now _that_ is a mess... \nI don't know about you, but it would take me quite a while to unravel what's happening here. The problem is that the whole expression is inside out. The `filter` gets applied first, but it's hidden in the middle of the expression, and the `sum` gets applied last but it is all the way in the front. Makes no sense...\n\nSo, how can we improve on this? `iterchain` of course! \n(you probably saw this coming already)\n\nSo, let's see how it looks using `iterchain`:\n```python\n>>> import iterchain\n>>> (iterchain.count(stop=100)\n... .filter(lambda x: x % 2 is 0)\n... .map(lambda x: x**2)\n... .sum())\n161700\n```\n\nIsn't this much better? The operations are listed in the order that they're executed, are clearly separated, and you can have as few or as many operations as you want. This is why you should use `iterchain`!\n\n\n## Iterator manipulation\n\nThe heart of this library ``<3``.\n\n\n## Generators\n\n`iterchain` also provides handy methods that let you build new `Iterator` instances from scratch. These are contained in the `iterchain.generators` sub-module, but they're also accessible directly from the `iterchain` module, which is the preferred way of using them.\n\nFor example:\n```\n >>> import iterchain\n >>> iterchain.count().take(4).map(lambda x: x**2).to_list()\n [0, 1, 4, 9]\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/Evelyn-H/iterchain", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://iterchain.readthedocs.io/en/stable/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "iterchain", "package_url": "https://pypi.org/project/iterchain/", "platform": "", "project_url": "https://pypi.org/project/iterchain/", "project_urls": { "Download": "https://github.com/Evelyn-H/iterchain", "Homepage": "https://iterchain.readthedocs.io/en/stable/" }, "release_url": "https://pypi.org/project/iterchain/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Simple and ergonomic iterator chaining for Python", "version": "0.1.3" }, "last_serial": 5105799, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0c192c90e346c3db2966526a0051aaa7", "sha256": "d506be5f815892c4f4af4516edc1876f0fe811cb399f9bd25c036e49d4a5a634" }, "downloads": -1, "filename": "iterchain-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0c192c90e346c3db2966526a0051aaa7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1890, "upload_time": "2019-04-01T22:27:56", "url": "https://files.pythonhosted.org/packages/53/da/51b52b210c2e5f129b4478f9f8b68dbfad1f1389e902f79fa111e4ea3754/iterchain-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff447885762ab37445d837ca81b63e17", "sha256": "328bd2a0fda75bef9d053fb1dc5184fba1b144c722b2aa03b4b4f4a0aa92830b" }, "downloads": -1, "filename": "iterchain-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ff447885762ab37445d837ca81b63e17", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 843, "upload_time": "2019-04-01T22:27:58", "url": "https://files.pythonhosted.org/packages/54/b7/18b42bc14ccc62174bd8e6b1e4302de4849d45f03dc281a43a308380db5e/iterchain-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "64863e378fb2e237a610bcbd3ed01188", "sha256": "15f85e8165f35fad7894c5818305e2854c69f9298c3037a4f3d10b33e855a5eb" }, "downloads": -1, "filename": "iterchain-0.1.0.tar.gz", "has_sig": false, "md5_digest": "64863e378fb2e237a610bcbd3ed01188", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1686, "upload_time": "2019-04-02T17:46:19", "url": "https://files.pythonhosted.org/packages/31/89/6577338808b07aa38eb068129fc3010b759763394ccedefab8e2a7a3976b/iterchain-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a028747698a227b714ba8827a904d648", "sha256": "a71b4e7afc2c35ab0d62ebf40b0020ce6608c9c5d8980c72171834d91a360187" }, "downloads": -1, "filename": "iterchain-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a028747698a227b714ba8827a904d648", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14460, "upload_time": "2019-04-03T21:09:38", "url": "https://files.pythonhosted.org/packages/1c/fe/3e40d31bdb80d413cd2eb330a2c1114a5d7fc3ba9fdd2136b92c85ad8893/iterchain-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3eb3c94f0ef752c8b66b783abdafd7d7", "sha256": "32b355c87aa20473ea6cba3691057034bfdfa8bc4c7c5efc2f55a4563b076980" }, "downloads": -1, "filename": "iterchain-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3eb3c94f0ef752c8b66b783abdafd7d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1811, "upload_time": "2019-04-03T21:09:39", "url": "https://files.pythonhosted.org/packages/41/26/993375bdf4be2f52112c5575fa10ffb2e9c6c41cb564de1d2be71b0777c6/iterchain-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "cfe25e82a3d055a94ea8daa623c14830", "sha256": "f59c19efa6a17af3b5feb341a3f49c30b512c5cab75b324cfd46e7cfe12f9123" }, "downloads": -1, "filename": "iterchain-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "cfe25e82a3d055a94ea8daa623c14830", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14629, "upload_time": "2019-04-03T21:28:48", "url": "https://files.pythonhosted.org/packages/d4/fb/2716f87a6fa6430aa218c835a411360221a11d8ceef2de0d9183eb227a77/iterchain-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0da237b6af06298769d135897b444428", "sha256": "8125bf41e949c73c2151e241f2ec2bbc555b52a9c2cdc00e2cf046c84e82f37f" }, "downloads": -1, "filename": "iterchain-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0da237b6af06298769d135897b444428", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1998, "upload_time": "2019-04-03T21:28:50", "url": "https://files.pythonhosted.org/packages/8d/24/789ff02a2e97c12e26736cd99c125bb3428a23be9061eb1c4707092da528/iterchain-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "486b6ea557cdd7e2f1121237ce413c58", "sha256": "2ea3c53f60fac69e5b9317ea2f2167d904ef53e491a4a55b8e7be0f2a61308c7" }, "downloads": -1, "filename": "iterchain-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "486b6ea557cdd7e2f1121237ce413c58", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17265, "upload_time": "2019-04-05T21:43:21", "url": "https://files.pythonhosted.org/packages/18/e5/a80242220b37642f16a3c5d5e3f3c056266098cad7fec9b266cafc6c8ea1/iterchain-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "237e09a0a633d3704abb1d29ad477280", "sha256": "bb932c41565a69aa0bdc4397b1df2878ef671d2ba676a5b4e50d414d04335a72" }, "downloads": -1, "filename": "iterchain-0.1.3.tar.gz", "has_sig": false, "md5_digest": "237e09a0a633d3704abb1d29ad477280", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4378, "upload_time": "2019-04-05T21:43:22", "url": "https://files.pythonhosted.org/packages/5e/94/bc53ba97a798e6586b74c1423ac26c6f7a34d96f9d10453c6d7faf3f44f7/iterchain-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "486b6ea557cdd7e2f1121237ce413c58", "sha256": "2ea3c53f60fac69e5b9317ea2f2167d904ef53e491a4a55b8e7be0f2a61308c7" }, "downloads": -1, "filename": "iterchain-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "486b6ea557cdd7e2f1121237ce413c58", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17265, "upload_time": "2019-04-05T21:43:21", "url": "https://files.pythonhosted.org/packages/18/e5/a80242220b37642f16a3c5d5e3f3c056266098cad7fec9b266cafc6c8ea1/iterchain-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "237e09a0a633d3704abb1d29ad477280", "sha256": "bb932c41565a69aa0bdc4397b1df2878ef671d2ba676a5b4e50d414d04335a72" }, "downloads": -1, "filename": "iterchain-0.1.3.tar.gz", "has_sig": false, "md5_digest": "237e09a0a633d3704abb1d29ad477280", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4378, "upload_time": "2019-04-05T21:43:22", "url": "https://files.pythonhosted.org/packages/5e/94/bc53ba97a798e6586b74c1423ac26c6f7a34d96f9d10453c6d7faf3f44f7/iterchain-0.1.3.tar.gz" } ] }