multithreading
A python module for creating multithreading processes easily, in a more Pythonic way.
Installation
pip install python-multithreading
example
import time
from multithreading import Caller, multi_threaded_call
def slow_function(number: int, delay: float) -> dict[str, int | float]:
for i in range(number):
time.sleep(delay)
return dict(number=number, delay=delay)
CALLS = 50
DELAY = 0.01
NUMBER = 100
callers = [
Caller(
target=slow_function,
kwargs=dict(delay=DELAY, number=NUMBER)
) for _ in range(CALLS)
]
s = time.time()
multi_threaded_call(callers)
e = time.time()
print("multi-threading: ", e - s)
s = e
all(slow_function(*caller.args, **caller.kwargs) for caller in callers)
e = time.time()
print("single-threading: ", e - s)
output
multi-threading: 1.0473840236663818
single-threading: 52.53497314453125
Metadata
Release files for python-multithreading 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-multithreading-0.0.1.tar.gz | 8.1 kB | Without provenance | Details for python-multithreading-0.0.1.tar.gz |
Release files / python-multithreading-0.0.1.tar.gz
| Download URL | python-multithreading-0.0.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55fbb7f495fd66ec71131253819dc7d0537f07ea7ae207b23af5bfa40a49626a
|
|
BLAKE2b-256 checksum How to use checksums |
ec7ec0e1aba363ed478448bb6d101021af9bc24ccda0da13a269a3cb628548d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for python-multithreading 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.