Skip to main content

Lightweight parallelisation library for Python

Project description

Citi

Citi/parfun

Lightweight parallelisation library for Python.

PyPI - Version


Parfun is a lightweight library providing helpers to make it easy to write and run a Python function in parallel and distributed systems.

The main feature of the library is its @parallel decorator that transparently executes standard Python functions following the map-reduce pattern:

from typing import List

import parfun as pf


@pf.parallel(
    split=pf.per_argument(
        values=pf.py_list.by_chunk
    ),
    combine_with=pf.py_list.concat,
)
def list_pow(values: List[float], factor: float) -> List[float]:
    return [v**factor for v in values]


if __name__ == "__main__":
    with pf.set_parallel_backend_context("local_multiprocessing"):  # use a local pool of processes
        print(list_pow([1, 2, 3], 2))  # runs in parallel, prints [1, 4, 9]

Features

  • Provides significant speedups to existing Python functions.
  • Only requires basic understanding of parallel and distributed computing systems.
  • Automatically estimates the optimal sub-task splitting strategy (the partition size).
  • Automatically handles data transmission, caching, and synchronization.
  • Supports various distributed computing backends:

Quick Start

Install Parfun directly from PyPI:

pip install parfun
pip install "parfun[pandas,scaler,dask]"  # with optional dependencies

The official documentation is available at citi.github.io/parfun/.

Take a look at our documentation's quickstart tutorial to get more examples and a deeper overview of the library.

Alternatively, you can build the HTML documentation from the source code:

cd docs
pip install -r requirements.txt
make html

The documentation's main page can then be found at docs/build/html/index.html.

Benchmarks

Parfun effectively parallelizes even short-duration functions.

When running a short 0.28-second ML function on an AMD Epyc 7313 16-Cores Processor, Parfun provides an impressive 7.4x speedup. Source code for this experiment here.

Benchmark Results

Contributing

Your contributions are at the core of making this a true open source project. Any contributions you make are greatly appreciated.

We welcome you to:

Please review our community contribution guidelines and functional contribution guidelines to get started 👍.

Code of Conduct

We are committed to making open source an enjoyable and respectful experience for our community. See CODE_OF_CONDUCT for more information.

License

This project is distributed under the Apache-2.0 License. See LICENSE for more information.

Contact

If you have a query or require support with this project, raise an issue. Otherwise, reach out to opensource@citi.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parfun-7.2.0.tar.gz (676.7 kB view details)

Uploaded Source

Built Distribution

parfun-7.2.0-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file parfun-7.2.0.tar.gz.

File metadata

  • Download URL: parfun-7.2.0.tar.gz
  • Upload date:
  • Size: 676.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for parfun-7.2.0.tar.gz
Algorithm Hash digest
SHA256 f1bf39c4349ed6d32f28f08a4c6d29e2b70f6bd9781b1d6a3eda28322e249225
MD5 a174a28f641488dd539df62ac95d6ce5
BLAKE2b-256 48bcc5f9630eb7e7acea3d0aa7c44072b5d3bd9eb91bbb4710f282d318f8c3a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for parfun-7.2.0.tar.gz:

Publisher: pypi.yml on Citi/parfun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parfun-7.2.0-py3-none-any.whl.

File metadata

  • Download URL: parfun-7.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for parfun-7.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc858b847459031964bb0199f6bda6e12a0931d1594d40691bb304248c1a40ad
MD5 187f2c8c113e31425ba83843e46b452e
BLAKE2b-256 c9f749df6748227e1a6e5c615512e7ddd2902c523f8db80cb9105474d6f44074

See more details on using hashes here.

Provenance

The following attestation bundles were made for parfun-7.2.0-py3-none-any.whl:

Publisher: pypi.yml on Citi/parfun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page