Skip to content

Instantly share code, notes, and snippets.

@0atman
0atman / pmap.py
Last active February 5, 2020 10:02
A process-based pmap with sensible defaults, ready to go
from multiprocessing import Pool
def pmap(f, collection, size=10):
"""
Applies `f` in parallel over `collection`.
Pool `size` has a sensible default of 10.
"""
with Pool(size) as p:
return p.map(f, collection)