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.5.tar.gz (2.3 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.5-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parallel_processing-0.1.5.tar.gz
  • Upload date:
  • Size: 2.3 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.5.tar.gz
Algorithm Hash digest
SHA256 50d3ba4f549a7d93ecd775e39a066cabb3984975c4f25c39b99480e3a0a5c323
MD5 3531dd90d7e4768d8bb016efce5bd8ff
BLAKE2b-256 d8be712d3ac108eeb6168cbc232424549f546032ba18a79024c89df3a1033505

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parallel_processing-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 efce9e2ef2af3fade69a12b58f30b474bcf23f00b7f72a12fee37b121cb342db
MD5 22cbd51d45f85c84b1391a8b7de1dd76
BLAKE2b-256 5e995f2f2c431d480a562a548fef86e028c445f6b0e076a855a7ca334dc6345d

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