{"id":33196615,"url":"https://github.com/MartinBernstorff/Iterpy","last_synced_at":"2025-11-21T02:01:11.855Z","repository":{"id":197194616,"uuid":"698157373","full_name":"MartinBernstorff/iterpy","owner":"MartinBernstorff","description":"⛓️ Iterators for Python with higher-order functions .map(), .filter() and .reduce() in a fluent interface. As seen in Rust, Java, Scala etc.","archived":false,"fork":false,"pushed_at":"2025-06-18T08:24:57.000Z","size":574,"stargazers_count":11,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T12:46:10.349Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MartinBernstorff.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-29T09:33:39.000Z","updated_at":"2025-10-26T13:41:14.000Z","dependencies_parsed_at":"2023-10-26T18:38:22.951Z","dependency_job_id":"c7a01b0a-6115-4a6d-9d3e-547b3d9d9770","html_url":"https://github.com/MartinBernstorff/iterpy","commit_stats":null,"previous_names":["martinbernstorff/functionalpython","martinbernstorff/functionalsequentialpython","martinbernstorff/iter","martinbernstorff/iterpy","martinbernstorff/functionalpy"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/MartinBernstorff/iterpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinBernstorff%2Fiterpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinBernstorff%2Fiterpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinBernstorff%2Fiterpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinBernstorff%2Fiterpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MartinBernstorff","download_url":"https://codeload.github.com/MartinBernstorff/iterpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinBernstorff%2Fiterpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285543732,"owners_count":27189594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-21T02:00:06.175Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-16T08:00:27.637Z","updated_at":"2025-11-21T02:01:11.850Z","avatar_url":"https://github.com/MartinBernstorff.png","language":"Python","funding_links":[],"categories":["Awesome Functional Python"],"sub_categories":["Libraries"],"readme":"# iterpy\n\n[![Open in Dev Container](https://img.shields.io/static/v1?label=Dev%20Containers\u0026message=Open\u0026color=blue\u0026logo=visualstudiocode)][dev container]\n[![PyPI](https://img.shields.io/pypi/v/iterpy.svg)][pypi status]\n[![Python Version](https://img.shields.io/pypi/pyversions/iterpy)][pypi status]\n[![Roadmap](https://img.shields.io/badge/Projects-Roadmap-green)][roadmap]\n\n[pypi status]: https://pypi.org/project/iterpy/\n[dev container]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/iterpy/\n[roadmap]: https://github.com/users/MartinBernstorff/projects/3/views/1?groupedBy%5BcolumnId%5D=70727793\u0026sliceBy%5BcolumnId%5D=Status\u0026filterQuery=-status%3ADone\n\n\u003c!-- start short-description --\u003e\n\nPython has implemented `map`, `filter` etc. as functions, rather than methods on a sequence. Since it does not contain a pipe operator, this makes the result harder to read. iterpy exists to change that.\n\nYou get this 🔥:\n\n```python\nfrom iterpy import Iter\n\nresult = Iter([1,2,3]).map(multiply_by_2).filter(is_even)\n```\n\nInstead of this:\n\n```python\nsequence = [1,2,3]\nmultiplied = [multiply_by_2(x) for x in sequence]\nresult = [x for x in multiplied if is_even(x)]\n```\n\nOr this:\n\n```python\nresult = filter(is_even, map(multiply_by_2, [1,2,3]))\n```\n\n\u003c!-- end short-description --\u003e\n\n## Install\n\n```bash\nuv add iterpy\n```\n\n## Usage\n```python\nfrom iterpy import Arr\n\nresult = (Arr([1, 2])\n            .filter(lambda x: x % 2 == 0)\n            .map(lambda x: x * 2)\n)\nassert result == [4]\n```\n\n\n```python\nfrom iterpy import Iter\n\nresult = (Iter([1, 2])\n            .filter(lambda x: x % 2 == 0)\n            .map(lambda x: x * 2)\n            .to_list()\n)\nassert result == [4]\n```\n\n### Lazy vs eager evaluation\n\nInspired by Polars, iterpy supports eager evaluation for easier debugging using `Arr`, and lazy evaluation for better performance using `Iter`. To access eager evaluation:\n\n```python\nfrom iterpy import Arr\n\nresult = Arr([1, 2, 3]).map(lambda x: x * 2).to_list()\nassert result == [2, 4, 6]\n```\n\n`Arr` acts like a Python `list`, so it has a super simple API you can [easily use anywhere](https://grugbrain.dev/#grug-on-apis).\n\nTo access lazy evaluation, just rename `Arr` to `Iter`:\n\n```python\nfrom iterpy import Iter\n\nresult = Iter([1, 2, 3]).map(lambda x: x * 2).to_list()\nassert result == [2, 4, 6]\n```\n\n## Prior art\n\niterpy stands on the shoulders of Scala, Rust etc.\n\nOther Python projects have had similar ideas:\n\n- [PyFunctional](https://github.com/EntilZha/PyFunctional) has existed for 7+ years with a comprehensive feature set. It is performant, with built-in lineage and caching. Unfortunately, this makes typing [non-trivial, with a 4+ year ongoing effort to add types](https://github.com/EntilZha/PyFunctional/issues/118).\n- [flupy](https://github.com/olirice/flupy) is highly similar, well typed, and mature. I had some issues with `.flatten()` not being type-hinted correctly, but but your mileage may vary.\n- Your library here? Feel free to make an issue if you have a good alternative!\n\n## Contributing\n\n### Setup\n\n1. We use [`uv`](https://docs.astral.sh/uv/) for environment management. Once it is installed, setup the dev environment using `make dev`.\n\nOr, use the devcontainer.\n\n1. Install [Orbstack](https://orbstack.dev/) or Docker Desktop. Make sure to complete the full install process before continuing.\n1. If not installed, install VSCode\n1. Press this [link](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/iterpy/)\n\n### Changes\n\n2. Make your changes\n\n3. See the makefile for tests, linting, and formatting.\n\n### Conventions\n\n- Make it work: Concise syntax borrowed from Scala, Rust etc.\n- Make it right: Fully typed, no exceptions\n- Make it fast:\n  - Concurrency through `.pmap`\n  - (Future): Caching\n  - (Future): Refactor operations to use generators\n- Keep it simple: No dependencies\n\n### API design\n\nAs a heuristic, we follow the APIs of:\n\n- Rust's [std::iter](https://doc.rust-lang.org/stable/std/iter/)\n- Rust's [itertools](https://docs.rs/itertools/latest/itertools/index.html)\n\nIn cases where this conflicts with typical python implementations, the API should be as predictable as possible for Python users.\n\n## 💬 Where to ask questions\n\n| Type                            |                        |\n| ------------------------------- | ---------------------- |\n| 🚨 **Bug Reports**              | [GitHub Issue Tracker] |\n| 🎁 **Feature Requests \u0026 Ideas** | [GitHub Issue Tracker] |\n| 👩‍💻 **Usage Questions**          | [GitHub Discussions]   |\n| 🗯 **General Discussion**        | [GitHub Discussions]   |\n\n[github issue tracker]: https://github.com/MartinBernstorff/iterpy/issues\n[github discussions]: https://github.com/MartinBernstorff/iterpy/discussions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMartinBernstorff%2FIterpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMartinBernstorff%2FIterpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMartinBernstorff%2FIterpy/lists"}