Convenient multiprocessing function for Python
Project description
tools-mp
This Python library provides a convenient one-line multiprocessing option that can be used as follows:
from tools_mp import multiprocess
from tools_mp import process
def any_function( arg_1, arg_2, ..., arg_n ):
do something
return result
args = [
{
'arg_1': arg_1,
'arg_2': arg_2,
...
'arg_n': arg_n,
} for arg_1, arg_2, ..., arg_n in arguments
]
data = multiprocess(
function = any_function,
args = args,
return_data = True,
verbose = True,
workers = 8,
**kwargs,
)
data = process(
function = any_function,
args = args,
return_data = True,
verbose = True,
workers = 8,
mp_threshold = 4, # <- if the number of tasks is less than this value,
# the process function will use single core processing, otherwise it
# will use multiprocessing. This can speed up the processing of small
# tasks significantly, as the overhead of multiprocessing is avoided.
**kwargs,
)
If verbose=True, the progress of the calculation will be visualized via the tqdm library. If workers=None (default) all available CPU cores will be used for processing. **kwargs will be passed to 'multiprocessing.Pool' as keyword arguments. This is important if you would like to initialize the workers with a specific function or variables for example.
Installation
pip install tools-mp
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tools_mp-0.3.0.tar.gz.
File metadata
- Download URL: tools_mp-0.3.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b290e323d7eec362c9a8b8fe4c50c50d1d70dc9ca4d770e341297d38d834671
|
|
| MD5 |
27305e0d672d82acd6a4af1acf165f9d
|
|
| BLAKE2b-256 |
8bb2b1070ec5a76e33166bb55b460692e362867f3b1c4e71103ffb44d80a87cc
|
File details
Details for the file tools_mp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tools_mp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56831a5b6b5ab4b31da9bf6b3ed4cc301f1f8bbe30f08fca2e4777b9665b380d
|
|
| MD5 |
828b0c620aa0bc2ca16b7630c2886346
|
|
| BLAKE2b-256 |
3378cccaa585db5f7debc2aa2b7d6747b621d2b61ed329b2b4b3e5a4d092def7
|