Func_Parallelizer is a simple Python module for parallel execution of functions using multiprocessing. Ideal for parallel execution of heavy cpu operations
Project description
func_parallelizer
Func_Parallelizer is a simple Python module for parallel execution of functions using multiprocessing.
Ideal for parallel execution of heavy cpu operations like processing huge no of files in a directory or reading files for pandas.
Installation
Use the package manager pip to install func_parallelizer.
pip install func-parallelizer
Usage
Import the required packages.
from func_parallelizer import parallel_runner
Create a class that has your function and arguments.
If your function doesn't require any arguments you can skip this and directly add them in tasks.
class task:
def __init__(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
def this(self):
consequences = do_this_with(self.arg1, self.arg2)
return consequences
def that(self):
consequences = do_that_with(self.arg1, self.arg2)
return consequences
Create objects using the above class.
def do_nothing():
print("Eat 5 Star")
print("⭐⭐⭐⭐⭐")
do = task(arg1, arg2)
Make a list of tasks you have to do.
Note: Don't use parentheses for functions otherwise function will execute in this stage also.
tasks = [
do.this,
do.that,
do_nothing
]
Pass the tasks to the parallel_runner function
By default all cores are used but if you have a life and want to do some other things, I would recommend to use 50% to 80% of your CPU cores.
total_mayhem = parallel_runner(tasks, cpu_cores=2)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
Feel free to ask any help(If it's about this package, dealing a lot IRL can't help yours too.)
License
Code of Conduct
Everyone interacting in the func-parallelizer project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PSF Code of Conduct.
Copyright © 2014, [The Python Packaging Authority].
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
File details
Details for the file func_parallelizer-0.4.1.tar.gz
.
File metadata
- Download URL: func_parallelizer-0.4.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3e1e8c46305491bbfb7cd4a3a4f5bc290f5aba579c4cf67a6e945cc1ec4acec |
|
MD5 | c1d28caa33a68b3dd3f19a4fdebb6f06 |
|
BLAKE2b-256 | d28ccfb2ceee9cda31e5ded59da91210b258219db93cd8dada17f557e4313cf4 |
File details
Details for the file func_parallelizer-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: func_parallelizer-0.4.1-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bb036f87e7205449b34235909ecac9a02d6dd67e9db95bef7b0f74e6ba7e29a |
|
MD5 | 710b8e8d03bf7d90940ad8d79d056442 |
|
BLAKE2b-256 | d7b596265561cdba543959d47a7523665609dc80685aeb24a01ae4e4937acf4d |