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.2.tar.gz (2.1 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.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parallel_processing-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 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.2.tar.gz
Algorithm Hash digest
SHA256 30726583fb3f096f36d1cbba5c2c014405fa40c18754a0d73cea3e21764c7805
MD5 b47f3b1da8e2b7a2e04ac1ec8f7f6ed2
BLAKE2b-256 70f7e2c98797b6f6a4b177b5e178e098b9a480fe89a33ecee6ab33945c7eef21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parallel_processing-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f83470f2d6c4d0d1c7318f59ae43fd54e209688f79e336e0bcd33e12d89b7a47
MD5 cb0979651750c244373717bbd9ca0694
BLAKE2b-256 a2c45d1c8a9df084eea02b19acfec10e432705f04200177b1cc06e78fbb556bc

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