Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

python-multithreading

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-multithreading

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

  • 0.0.1
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc