Lightweight parallelisation library for Python
Project description
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:
- Python's built-in multiprocessing module.
- Scaler.
- Dask.
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.
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:
- Fix typos or touch up documentation
- Share your opinions on existing issues
- Help expand and improve our library by opening a new issue
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1bf39c4349ed6d32f28f08a4c6d29e2b70f6bd9781b1d6a3eda28322e249225 |
|
MD5 | a174a28f641488dd539df62ac95d6ce5 |
|
BLAKE2b-256 | 48bcc5f9630eb7e7acea3d0aa7c44072b5d3bd9eb91bbb4710f282d318f8c3a4 |
Provenance
The following attestation bundles were made for parfun-7.2.0.tar.gz
:
Publisher:
pypi.yml
on Citi/parfun
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
parfun-7.2.0.tar.gz
- Subject digest:
f1bf39c4349ed6d32f28f08a4c6d29e2b70f6bd9781b1d6a3eda28322e249225
- Sigstore transparency entry: 199389490
- Sigstore integration time:
- Permalink:
Citi/parfun@263108b6c8ebeb43969e6b13c580060c7af999d1
- Branch / Tag:
refs/tags/v7.2.0
- Owner: https://github.com/Citi
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
pypi.yml@263108b6c8ebeb43969e6b13c580060c7af999d1
- Trigger Event:
release
- Statement type:
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc858b847459031964bb0199f6bda6e12a0931d1594d40691bb304248c1a40ad |
|
MD5 | 187f2c8c113e31425ba83843e46b452e |
|
BLAKE2b-256 | c9f749df6748227e1a6e5c615512e7ddd2902c523f8db80cb9105474d6f44074 |
Provenance
The following attestation bundles were made for parfun-7.2.0-py3-none-any.whl
:
Publisher:
pypi.yml
on Citi/parfun
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
parfun-7.2.0-py3-none-any.whl
- Subject digest:
bc858b847459031964bb0199f6bda6e12a0931d1594d40691bb304248c1a40ad
- Sigstore transparency entry: 199389492
- Sigstore integration time:
- Permalink:
Citi/parfun@263108b6c8ebeb43969e6b13c580060c7af999d1
- Branch / Tag:
refs/tags/v7.2.0
- Owner: https://github.com/Citi
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
pypi.yml@263108b6c8ebeb43969e6b13c580060c7af999d1
- Trigger Event:
release
- Statement type: