Skip to main content

Plug 'n' play multithreaded for

Project description

What is mtfor

"mtfor" or "multithreaded for" is a simple package that provides a for loop that automatically distributes the processing through a number of threads.

Installation

You can use pip3 to install this utility by executing:

pip3 install mtfor

Usage

The function signature is mtfor(list, function, number_of_threads). It returns your list already modified.

This example prints the result of applying my_function to my_list using 4 threads.

from mtfor import mtfor

NUM_THREADS = 4

def my_function(x):
  return x * x

my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
modified_list = mtfor(my_list, my_function, NUM_THREADS)

print(modified_list)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mtfor, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size mtfor-0.0.4-py3-none-any.whl (14.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page