ppft: Parallel Python Framework
ppft is a friendly fork of Parallel Python (pp), designed to provide distributed and parallel Python capabilities on Symmetric Multi-Processing (SMP) systems and clusters. It offers an easier installation process and enhanced serialization through the optional `dill` library. Currently at version 1.7.8, ppft maintains an active development and release cadence, with recent updates focused on Python 3 compatibility and dropping support for older Python versions.
Warnings
- breaking Python 2.x support was dropped in early versions, and Python 3.x minimum requirements have increased incrementally. Version 1.7.8 requires Python >=3.9, and upcoming versions (e.g., 1.7.9.dev0 documentation) indicate a requirement of Python >=3.10. Ensure your Python environment meets the specific version's requirements.
- gotcha ppft installs itself as the 'pp' module. If the original 'Parallel Python' (pp) library is already installed in your environment, 'import pp' may point to the original library instead of the ppft fork. This can lead to unexpected behavior or missing features.
- gotcha For enhanced serialization of complex Python objects (e.g., lambdas, nested functions, objects with custom serialization), it is highly recommended to install ppft with the optional 'dill' dependency. Without it, some objects might fail to serialize correctly for parallel execution.
Install
-
pip install ppft -
pip install ppft[dill]
Imports
- Server
import pp job_server = pp.Server()
- pp
import pp
Quickstart
import pp
import math
def my_function(a, b):
return math.sqrt(a**2 + b**2)
# Create a job server
# The number of workers can be specified, e.g., pp.Server(4)
job_server = pp.Server()
# Submit jobs
jobs = []
for i in range(10):
jobs.append(job_server.submit(my_function, (i, i+1), ())) # func, args, modules
# Retrieve results
results = [job() for job in jobs]
print(f"Calculated results: {results}")
# Destroy the job server
job_server.destroy()