python-multithreading


Namepython-multithreading JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/Shahaf-F-S/multithreading
SummaryA python module for creating multithreading processes easily, in a more Pythonic way.
upload_time2024-01-27 09:22:05
maintainer
docs_urlNone
authorShahaf Frank-Shapir
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # multithreading

> A python module for creating multithreading processes easily, in a more Pythonic way.

## Installation
```
pip install python-multithreading
```

## example

```python
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
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Shahaf-F-S/multithreading",
    "name": "python-multithreading",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Shahaf Frank-Shapir",
    "author_email": "shahaffrs@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ec/7e/c0e1aba363ed478448bb6d101021af9bc24ccda0da13a269a3cb628548d4/python-multithreading-0.0.1.tar.gz",
    "platform": null,
    "description": "# multithreading\r\n\r\n> A python module for creating multithreading processes easily, in a more Pythonic way.\r\n\r\n## Installation\r\n```\r\npip install python-multithreading\r\n```\r\n\r\n## example\r\n\r\n```python\r\nimport time\r\n\r\nfrom multithreading import Caller, multi_threaded_call\r\n\r\ndef slow_function(number: int, delay: float) -> dict[str, int | float]:\r\n\r\n    for i in range(number):\r\n        time.sleep(delay)\r\n\r\n    return dict(number=number, delay=delay)\r\n\r\nCALLS = 50\r\nDELAY = 0.01\r\nNUMBER = 100\r\n\r\ncallers = [\r\n    Caller(\r\n        target=slow_function,\r\n        kwargs=dict(delay=DELAY, number=NUMBER)\r\n    ) for _ in range(CALLS)\r\n]\r\n\r\ns = time.time()\r\n\r\nmulti_threaded_call(callers)\r\n\r\ne = time.time()\r\n\r\nprint(\"multi-threading: \", e - s)\r\n\r\ns = e\r\n\r\nall(slow_function(*caller.args, **caller.kwargs) for caller in callers)\r\n\r\ne = time.time()\r\n\r\nprint(\"single-threading: \", e - s)\r\n```\r\n\r\noutput\r\n```\r\nmulti-threading: 1.0473840236663818\r\nsingle-threading: 52.53497314453125\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python module for creating multithreading processes easily, in a more Pythonic way.",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/Shahaf-F-S/multithreading"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec7ec0e1aba363ed478448bb6d101021af9bc24ccda0da13a269a3cb628548d4",
                "md5": "fd8083142ac069d3190f527e1bd6464b",
                "sha256": "55fbb7f495fd66ec71131253819dc7d0537f07ea7ae207b23af5bfa40a49626a"
            },
            "downloads": -1,
            "filename": "python-multithreading-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fd8083142ac069d3190f527e1bd6464b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8074,
            "upload_time": "2024-01-27T09:22:05",
            "upload_time_iso_8601": "2024-01-27T09:22:05.637723Z",
            "url": "https://files.pythonhosted.org/packages/ec/7e/c0e1aba363ed478448bb6d101021af9bc24ccda0da13a269a3cb628548d4/python-multithreading-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-27 09:22:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Shahaf-F-S",
    "github_project": "multithreading",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "python-multithreading"
}
        
Elapsed time: 0.27596s