Skip to main content

No project description provided

Project description

Parallel Processing

PyPI version

A minimal, easy-to-use Python utility to parallelize function execution using threads or processes.
This library helps you speed up processing over iterable items by distributing work across multiple workers.


Features

  • Lightweight and dependency-free
  • Simple interface for threading and multiprocessing
  • Easily process a list of items with any custom function
  • Ideal for I/O-bound or CPU-bound tasks

Installation

pip install parallel-processing

Usage

You can use either threading or multiprocessing to parallelize your task over a list of items.

Example: Using Threads

from parallel_processing import ParallelProcessing

def fetch(x):
    print(f"Processing item: {x}")

workers = 10
its = 100

ParallelProcessing.thread(
    workers=workers,
    processor=fetch,
    items=range(its)
)

Example: Using Processes

from parallel_processing import ParallelProcessing

def compute(x):
    return x * x

results = ParallelProcessing.process(
    workers=4,
    processor=compute,
    items=range(10)
)

print(list(results))

API

ParallelProcessing.thread(workers, processor, items)

Runs processor(item) for each item in items using workers threads.

  • workers (int): Number of threads to use
  • processor (callable): Function to apply to each item
  • items (iterable): The list or iterable of items to process

ParallelProcessing.process(workers, processor, items)

Runs processor(item) for each item in items using workers processes and returns results.

  • workers (int): Number of processes to use
  • processor (callable): Function to apply to each item
  • items (iterable): The list or iterable of items to process

License

MIT License


Author

Louis Nguyen
louis.nguyen@qode.world

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

parallel_processing-0.1.3.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallel_processing-0.1.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file parallel_processing-0.1.3.tar.gz.

File metadata

  • Download URL: parallel_processing-0.1.3.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.8.0-1033-gcp

File hashes

Hashes for parallel_processing-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5273a85e8c34699c81d3ba41ba18907c838e552a2a7a8c235bf6022ab7040579
MD5 619ab7ed96f84176fb0d09a4046eccbd
BLAKE2b-256 fc293572dbcd7e067bdc00d8e493d511e2ee4f9735075372f279d249cec49796

See more details on using hashes here.

File details

Details for the file parallel_processing-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: parallel_processing-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.8.0-1033-gcp

File hashes

Hashes for parallel_processing-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 762a9fa6fb004ee29ea014b6719afb0168e852a08f4d2003c369a4ac25a96cc4
MD5 d59b7b6f8189fe97f8bf4ecbdfd55df6
BLAKE2b-256 53f7374b757afd25a0a648dbca5ccc858c1dd5fe2a00a3d0d30c8a55effbea51

See more details on using hashes here.

Supported by

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