A library offers streamlined utilities to simplify the parallelization of Python functions
Project description
Pyllelize
Easily parallelize your Python functions with pyllelize
. Whether you're dealing with CPU-bound tasks or I/O-bound asynchronous functions, pyllelize
offers a simple interface to distribute your workload efficiently.
Key Features
-
Thread-based Parallelization: Distribute CPU-bound tasks across multiple threads with ease.
-
Process-based Parallelization: Harness the full power of multi-core processors by distributing tasks across separate processes, bypassing Python's Global Interpreter Lock.
-
Asynchronous Execution: Seamlessly parallelize I/O-bound asynchronous tasks.
-
Error Handling: Safely capture and report errors without halting the execution of other tasks.
Installation
pip install pyllelize
Quick Start
Thread-based Execution
from pyllelize import parallel_execute_threads
def multiply(a, b):
return a * b
arguments = [(1, 2), (3, 4), (5, 6)]
results = parallel_execute_threads(multiply, arguments)
print(results) # Possible output: [2, 12, 30]
Process-based Execution
from pyllelize import parallel_execute_processes
def add(a, b):
return a + b
arguments = [(1, 2), (3, 4), (5, 6)]
results = parallel_execute_processes(add, arguments)
print(results) # Possible output: [3, 7, 11]
Asynchronous Execution
import asyncio
from pyllelize import parallel_execute_threads_async
async def fetch_data(a, b):
await asyncio.sleep(1) # Simulating async I/O operation
return a + b
arguments = [(1, 2), (3, 4), (5, 6)]
results = parallel_execute_threads_async(fetch_data, arguments)
print(results) # Possible output after 1 second: [3, 7, 11]
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
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 pyllelize-0.1.1.tar.gz
.
File metadata
- Download URL: pyllelize-0.1.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5878a825721dec9fc66fb5401861e87542dfd49d824e11f6b81a013a9e8433d7 |
|
MD5 | 838d91638dfeabfb2437600677c60fc6 |
|
BLAKE2b-256 | 03fef81e8696c0068b73201199e04d86bda30a07aaced3c8adffc8fe16ff503e |
File details
Details for the file pyllelize-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyllelize-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3718c841c34755d3e7840b8ab0525ec8c188f503d16333e429a833494bd35a |
|
MD5 | c200573aa14e7bbd409b02202350f235 |
|
BLAKE2b-256 | b723864f6f6d568cfa4785fa7c98782918c5cbe1c75a502544038b1125ec9abb |