{"id":25235368,"url":"https://github.com/didactic-meme/pyfuncol","last_synced_at":"2025-10-08T18:00:07.423Z","repository":{"id":37471381,"uuid":"439068971","full_name":"didactic-meme/pyfuncol","owner":"didactic-meme","description":"Functional collections extension functions for Python","archived":false,"fork":false,"pushed_at":"2024-04-29T21:06:53.000Z","size":3068,"stargazers_count":32,"open_issues_count":9,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-29T23:02:59.660Z","etag":null,"topics":["collections","extension-functions","functional","parallel","python","python3"],"latest_commit_sha":null,"homepage":"https://pyfuncol.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/didactic-meme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"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},"funding":{"custom":["paypal.me/gondolav"]}},"created_at":"2021-12-16T17:11:16.000Z","updated_at":"2022-11-16T10:31:37.000Z","dependencies_parsed_at":"2024-04-29T22:38:47.633Z","dependency_job_id":null,"html_url":"https://github.com/didactic-meme/pyfuncol","commit_stats":{"total_commits":98,"total_committers":6,"mean_commits":"16.333333333333332","dds":"0.47959183673469385","last_synced_commit":"562a329028ed1c47cba6bf0906832b45c70ae5c3"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didactic-meme%2Fpyfuncol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didactic-meme%2Fpyfuncol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didactic-meme%2Fpyfuncol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didactic-meme%2Fpyfuncol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/didactic-meme","download_url":"https://codeload.github.com/didactic-meme/pyfuncol/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238310547,"owners_count":19450884,"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","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":["collections","extension-functions","functional","parallel","python","python3"],"created_at":"2025-02-11T14:33:23.397Z","updated_at":"2025-10-08T18:00:00.649Z","avatar_url":"https://github.com/didactic-meme.png","language":"Python","funding_links":["paypal.me/gondolav"],"categories":[],"sub_categories":[],"readme":"# pyfuncol\n\n![CI](https://github.com/didactic-meme/pyfuncol/actions/workflows/python-app.yml/badge.svg)\n[![codecov](https://codecov.io/gh/didactic-meme/pyfuncol/branch/main/graph/badge.svg)](https://codecov.io/gh/didactic-meme/pyfuncol)\n![PyPI](https://img.shields.io/pypi/v/pyfuncol?color=blue)\n[![Downloads](https://pepy.tech/badge/pyfuncol)](https://pepy.tech/project/pyfuncol)\n[![Documentation Status](https://readthedocs.org/projects/pyfuncol/badge/?version=latest)](https://pyfuncol.readthedocs.io/en/latest/?badge=latest)\n[![GitHub license](https://img.shields.io/github/license/didactic-meme/pyfuncol)](https://github.com/didactic-meme/pyfuncol/blob/main/LICENSE)\n\n- [pyfuncol](#pyfuncol)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Usage without forbiddenfruit](#usage-without-forbiddenfruit)\n    - [API](#api)\n  - [Documentation](#documentation)\n  - [Compatibility](#compatibility)\n  - [Contributing](#contributing)\n  - [License](#license)\n\nA Python functional collections library. It _extends_ collections built-in types with useful methods to write functional Python code. It uses [Forbidden Fruit](https://github.com/clarete/forbiddenfruit) under the hood.\n\npyfuncol provides:\n\n- Standard \"eager\" methods, such as `map`, `flat_map`, `group_by`, etc.\n- Parallel methods, such as `par_map`, `par_flat_map`, etc.\n- Pure methods that leverage memoization to improve performance, such as `pure_map`, `pure_flat_map`, etc.\n- Lazy methods that return iterators and never materialize results, such as `lazy_map`, `lazy_flat_map`, etc.\n\npyfuncol can also be [used without forbiddenfruit](#usage-without-forbiddenfruit).\n\n## Installation\n\n`pip install pyfuncol`\n\n## Usage\n\n\u003e **Note:** If you are not using forbiddenfruit, the functions will not extend the builtins. Please [see here](#usage-without-forbiddenfruit) for usage without forbiddenfruit.\n\nTo use the methods, you just need to import pyfuncol. Some examples:\n\n```python\nimport pyfuncol\n\n[1, 2, 3, 4].map(lambda x: x * 2).filter(lambda x: x \u003e 4)\n# [6, 8]\n\n[1, 2, 3, 4].fold_left(0, lambda acc, n: acc + n)\n# 10\n\n{1, 2, 3, 4}.map(lambda x: x * 2).filter_not(lambda x: x \u003c= 4)\n# {6, 8}\n\n[\"abc\", \"def\", \"e\"].group_by(lambda s: len(s))\n# {3: [\"abc\", \"def\"], 1: [\"e\"]}\n\n{\"a\": 1, \"b\": 2, \"c\": 3}.flat_map(lambda kv: {kv[0]: kv[1] ** 2})\n# {\"a\": 1, \"b\": 4, \"c\": 9}\n```\n\npyfuncol provides parallel operations (for now `par_map`, `par_flat_map`, `par_filter` and `par_filter_not`):\n\n```python\n[1, 2, 3, 4].par_map(lambda x: x * 2).par_filter(lambda x: x \u003e 4)\n# [6, 8]\n\n{1, 2, 3, 4}.par_map(lambda x: x * 2).par_filter_not(lambda x: x \u003c= 4)\n# {6, 8}\n\n{\"a\": 1, \"b\": 2, \"c\": 3}.par_flat_map(lambda kv: {kv[0]: kv[1] ** 2})\n# {\"a\": 1, \"b\": 4, \"c\": 9}\n```\n\npyfuncol provides operations leveraging memoization to improve performance (for now `pure_map`, `pure_flat_map`, `pure_filter` and `pure_filter_not`). These versions work only for **pure** functions (i.e., all calls to the same args return the same value) on hashable inputs:\n\n```python\n[1, 2, 3, 4].pure_map(lambda x: x * 2).pure_filter(lambda x: x \u003e 4)\n# [6, 8]\n\n{1, 2, 3, 4}.pure_map(lambda x: x * 2).pure_filter_not(lambda x: x \u003c= 4)\n# {6, 8}\n\n{\"a\": 1, \"b\": 2, \"c\": 3}.pure_flat_map(lambda kv: {kv[0]: kv[1] ** 2})\n# {\"a\": 1, \"b\": 4, \"c\": 9}\n```\n\npyfuncol provides lazy operations that never materialize results:\n\n```python\nlist([1, 2, 3, 4].lazy_map(lambda x: x * 2).lazy_filter(lambda x: x \u003e 4))\n# [6, 8]\n\nlist({1, 2, 3, 4}.lazy_map(lambda x: x * 2).lazy_filter_not(lambda x: x \u003c= 4))\n# [6, 8]\n\nlist({\"a\": 1, \"b\": 2, \"c\": 3}.lazy_flat_map(lambda kv: {kv[0]: kv[1] ** 2}))\n# [(\"a\", 1), (\"b\", 4), (\"c\", 9)]\n\nset([1, 2, 3, 4].lazy_map(lambda x: x * 2).lazy_filter(lambda x: x \u003e 4))\n# {6, 8}\n```\n\n### Usage without forbiddenfruit\n\nIf you are using a Python interpreter other than CPython, forbiddenfruit will not work.\n\nFortunately, if forbiddenfruit does not work on your installation or if you do not want to use it, pyfuncol also supports direct function calls without extending builtins.\n\n```python\nfrom pyfuncol import list as pfclist\n\npfclist.map([1, 2, 3], lambda x: x * 2)\n# [2, 4, 6]\n```\n\n### API\n\nFor lists, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.list).\n\nFor dictionaries, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.dict).\n\nFor sets and frozensets, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.set).\n\nFor more details, please have a look at the [API reference](https://pyfuncol.readthedocs.io/en/latest/modules.html).\n\nWe support all subclasses with default constructors (`OrderedDict`, for example).\n\n## Documentation\n\nSee \u003chttps://pyfuncol.readthedocs.io/\u003e.\n\n## Compatibility\n\nFor functions to extend built-ins, [Forbidden Fruit](https://github.com/clarete/forbiddenfruit) is necessary (CPython only).\n\n## Contributing\n\nSee the [contributing guide](https://github.com/didactic-meme/pyfuncol/blob/main/CONTRIBUTING.md) for detailed instructions on how to get started with the project.\n\n## License\n\npyfuncol is licensed under the [MIT license](https://github.com/didactic-meme/pyfuncol/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidactic-meme%2Fpyfuncol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidactic-meme%2Fpyfuncol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidactic-meme%2Fpyfuncol/lists"}