Metadata-Version: 2.1
Name: pyfuncol
Version: 1.1
Summary: Functional collections extension functions for Python
Home-page: https://github.com/Gondolav/pyfuncol
Author: Andrea Veneziano
Author-email: andrea.veneziano@icloud.com
Maintainer: Andrea Veneziano
Maintainer-email: andrea.veneziano@icloud.com
License: MIT
Keywords: functional pipeline data collection chain parallel
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: forbiddenfruit

# pyfuncol

![CI](https://github.com/Gondolav/pyfuncol/actions/workflows/python-app.yml/badge.svg)
[![codecov](https://codecov.io/gh/Gondolav/pyfuncol/branch/main/graph/badge.svg)](https://codecov.io/gh/Gondolav/pyfuncol)
![PyPI](https://img.shields.io/pypi/v/pyfuncol?color=blue)
[![Downloads](https://pepy.tech/badge/pyfuncol/month)](https://pepy.tech/project/pyfuncol)
[![Documentation Status](https://readthedocs.org/projects/pyfuncol/badge/?version=latest)](https://pyfuncol.readthedocs.io/en/latest/?badge=latest)
[![GitHub license](https://img.shields.io/github/license/Gondolav/pyfuncol)](https://github.com/Gondolav/pyfuncol/blob/main/LICENSE)

- [pyfuncol](#pyfuncol)
  - [Installation](#installation)
  - [Usage](#usage)
    - [API](#api)
  - [Documentation](#documentation)
  - [Compatibility](#compatibility)
  - [Contributing](#contributing)
  - [License](#license)

A 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.

## Installation

`pip install pyfuncol`

## Usage

To use the methods, you just need to import pyfuncol. Some examples:

```python
import pyfuncol

[1, 2, 3, 4].map(lambda x: x * 2).filter(lambda x: x > 4)
# [6, 8]

[1, 2, 3, 4].fold_left(0, lambda acc, n: acc + n)
# 10

{1, 2, 3, 4}.map(lambda x: x * 2).filter_not(lambda x: x <= 4)
# {6, 8}

["abc", "def", "e"].group_by(lambda s: len(s))
# {3: ["abc", "def"], 1: ["e"]}

{"a": 1, "b": 2, "c": 3}.flat_map(lambda kv: {kv[0]: kv[1] ** 2})
# {"a": 1, "b": 4, "c": 9}

# pyfuncol also provides some parallel operations

[1, 2, 3, 4].par_map(lambda x: x * 2).par_filter(lambda x: x > 4)
# [6, 8]

{1, 2, 3, 4}.par_map(lambda x: x * 2).par_filter(lambda x: x > 4)
# {6, 8}

{"a": 1, "b": 2, "c": 3}.par_flat_map(lambda kv: {kv[0]: kv[1] ** 2})
# {"a": 1, "b": 4, "c": 9}
```

### API

For lists, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.list).

For dictionaries, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.dict).

For sets, please refer to the [docs](https://pyfuncol.readthedocs.io/en/latest/pyfuncol.html#module-pyfuncol.set).

For more details, please have a look at the [API reference](https://pyfuncol.readthedocs.io/en/latest/modules.html).

## Documentation

See <https://pyfuncol.readthedocs.io/>.

## Compatibility

Since it depends on [Forbidden Fruit](https://github.com/clarete/forbiddenfruit), it only works on CPython.

## Contributing

See the [contributing guide](https://github.com/Gondolav/pyfuncol/blob/main/CONTRIBUTING.md) for detailed instructions on how to get started with the project.

## License

pyfuncol is licensed under the [MIT license](https://github.com/Gondolav/pyfuncol/blob/main/LICENSE).


