Ultima - intuitive parallel map() for Python
What is it?
ultima is a Python package that provides a simple yet powerful interface to do map() in parallel.
It uses concurrent.futures as its execution backend and can run tasks in either threads or sub-processes.
It is designed to squeeze maximum performance (let those CPUs burn 🔥) with the same simple interface.
Usage examples:
Run a heavy function in sub-processes:
from ultima import Workforce
inputs = open("input_data.txt")
with Workforce() as wf:
for result in wf.map(cpu_intensive_function, inputs):
...
An equivalent one-liner:
from ultima import ultimap
for result in ultimap(cpu_intensive_function, inputs):
...
The default backend is multiprocessing, but you can easily use threads instead:
from ultima import ultimap
for result in ultimap(io_bound_function, inputs, backend='threading', n_workers=64):
...
To chain an IO-intensive task with a CPU-intensive task:
from ultima import ultimap
def io_intensive(url):
import requests
return requests.get(url).text
def cpu_intensive(page):
import hashlib
return hashlib.sha1(page.encode()).hexdigest()
urls = open("urls.txt")
webpages = ultimap(io_intensive, urls, backend='threading', n_workers=64)
hashes = ultimap(cpu_intensive, webpages, backend='multiprocessing')
print(len(set(hashes)))
You can also map a function recursively:
from ultima import ultimap
def visit(graph, node, add_input):
for child_node in graph.get_children(node):
add_input(graph, child_node)
return f"visited {node}"
print(list(ultimap(visit, [(graph, graph.root)], recursive=True)))
Metadata
Release files for ultima 1.2.0
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 |
|---|---|---|---|---|
| ultima-1.2.0.tar.gz | 19.1 kB | Without provenance | Details for ultima-1.2.0.tar.gz |
Release files / ultima-1.2.0.tar.gz
| Download URL | ultima-1.2.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b03b2f65c6f0d86e421eed79217f60928367bc34046487ec676f7539c8def08
|
|
BLAKE2b-256 checksum How to use checksums |
7752ac134698587cd7e638416f3ee9463088c4ce093375cfc764edf7cec762a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0
|
Security for ultima 1.2.0
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.