Multiprocessing
say it: “mul-tee-PRAH-ses-ing” /ˌmʌltiˈprɑsɛsɪŋ/
Runs work in separate processes so heavy calculations run in parallel.
What is multiprocessing?
Multiprocessing runs work in separate processes, one per CPU core, so heavy number crunching really does run in parallel.
from multiprocessing import Pool
def resize(photo):
return f"{photo} resized"
if __name__ == "__main__":
with Pool() as pool:
print(pool.map(resize, ["a.jpg", "b.jpg", "c.jpg"]))
Level: Freelancer · More Python terms at this level
Updated