I think the Pool class is typically more convenient, but it depends whether you want your results ordered or unordered.

Say you want to create 4 random strings (e.g,. could be a random user ID generator or so):

import multiprocessing as mp
import random
import string

# Define an output queue
output = mp.Queue()

# define a example function
def rand_string(length, output):
    """ Generates a random string of numbers, lower- and uppercase chars. """
    rand_str = ''.join(random.choice(
                    string.ascii_lowercase
                    + string.ascii_uppercase
                    + string.digits)
               for i in range(length))
    output.put(rand_str)

# Setup a list of processes that we want to run
processes = [mp.Process(target=rand_string, args=(5, output)) for x in range(4)]

# Run processes
for p in processes:
    p.start()

# Exit the completed processes
for p in processes:
    p.join()

# Get process results from the output queue
results = [output.get() for p in processes]

print(results)

# Output
# ['yzQfA', 'PQpqM', 'SHZYV', 'PSNkD']

Here, the order probably doesn't matter. I am not sure if there is a better way to do it, but if I want to keep track of results in the order in which the functions are called, I typically return tuples with an ID as first item, e.g.,

# define a example function
def rand_string(length, pos, output):
    """ Generates a random string of numbers, lower- and uppercase chars. """
    rand_str = ''.join(random.choice(
                    string.ascii_lowercase
                    + string.ascii_uppercase
                    + string.digits)
                for i in range(length))
    output.put((pos, rand_str))

# Setup a list of processes that we want to run
processes = [mp.Process(target=rand_string, args=(5, x, output)) for x in range(4)]

print(processes)

# Output
# [(1, '5lUya'), (3, 'QQvLr'), (0, 'KAQo6'), (2, 'nj6Q0')]

This let's me sort the results then:

results.sort()
results = [r[1] for r in results]
print(results)

# Output:
# ['KAQo6', '5lUya', 'nj6Q0', 'QQvLr']

The Pool class

Now to your question: How is this different from the Pool class? You'd typically prefer Pool.map to return ordered list of results without going through the hoop of creating tuples and sorting them by ID. Thus, I would say it is typically more efficient.

def cube(x):
    return x**3

pool = mp.Pool(processes=4)
results = pool.map(cube, range(1,7))
print(results)

# output:
# [1, 8, 27, 64, 125, 216]

Equivalently, there is also an "apply" method:

pool = mp.Pool(processes=4)
results = [pool.apply(cube, args=(x,)) for x in range(1,7)]
print(results)

# output:
# [1, 8, 27, 64, 125, 216]

Both Pool.apply and Pool.map will lock the main program until a process has finished.

Now, you also have Pool.apply_async and Pool.map_async, which return the result as soon as the process has finished, which is essentially similar to the Process class above. The advantage may be that they provide you with the convenient apply and map functionality that you know from Python's in-built apply and map

Answer from user2489252 on Stack Overflow
🌐
Python
docs.python.org › 3 › library › multiprocessing.html
multiprocessing — Process-based parallelism
The multiprocessing module also introduces the Pool object which offers a convenient means of parallelizing the execution of a function across multiple input values, distributing the input data across processes (data parallelism).
Top answer
1 of 2
35

I think the Pool class is typically more convenient, but it depends whether you want your results ordered or unordered.

Say you want to create 4 random strings (e.g,. could be a random user ID generator or so):

import multiprocessing as mp
import random
import string

# Define an output queue
output = mp.Queue()

# define a example function
def rand_string(length, output):
    """ Generates a random string of numbers, lower- and uppercase chars. """
    rand_str = ''.join(random.choice(
                    string.ascii_lowercase
                    + string.ascii_uppercase
                    + string.digits)
               for i in range(length))
    output.put(rand_str)

# Setup a list of processes that we want to run
processes = [mp.Process(target=rand_string, args=(5, output)) for x in range(4)]

# Run processes
for p in processes:
    p.start()

# Exit the completed processes
for p in processes:
    p.join()

# Get process results from the output queue
results = [output.get() for p in processes]

print(results)

# Output
# ['yzQfA', 'PQpqM', 'SHZYV', 'PSNkD']

Here, the order probably doesn't matter. I am not sure if there is a better way to do it, but if I want to keep track of results in the order in which the functions are called, I typically return tuples with an ID as first item, e.g.,

# define a example function
def rand_string(length, pos, output):
    """ Generates a random string of numbers, lower- and uppercase chars. """
    rand_str = ''.join(random.choice(
                    string.ascii_lowercase
                    + string.ascii_uppercase
                    + string.digits)
                for i in range(length))
    output.put((pos, rand_str))

# Setup a list of processes that we want to run
processes = [mp.Process(target=rand_string, args=(5, x, output)) for x in range(4)]

print(processes)

# Output
# [(1, '5lUya'), (3, 'QQvLr'), (0, 'KAQo6'), (2, 'nj6Q0')]

This let's me sort the results then:

results.sort()
results = [r[1] for r in results]
print(results)

# Output:
# ['KAQo6', '5lUya', 'nj6Q0', 'QQvLr']

The Pool class

Now to your question: How is this different from the Pool class? You'd typically prefer Pool.map to return ordered list of results without going through the hoop of creating tuples and sorting them by ID. Thus, I would say it is typically more efficient.

def cube(x):
    return x**3

pool = mp.Pool(processes=4)
results = pool.map(cube, range(1,7))
print(results)

# output:
# [1, 8, 27, 64, 125, 216]

Equivalently, there is also an "apply" method:

pool = mp.Pool(processes=4)
results = [pool.apply(cube, args=(x,)) for x in range(1,7)]
print(results)

# output:
# [1, 8, 27, 64, 125, 216]

Both Pool.apply and Pool.map will lock the main program until a process has finished.

Now, you also have Pool.apply_async and Pool.map_async, which return the result as soon as the process has finished, which is essentially similar to the Process class above. The advantage may be that they provide you with the convenient apply and map functionality that you know from Python's in-built apply and map

2 of 2
3

You can easily do this with pypeln:

import pypeln as pl

stage = pl.process.map(
    CreateMatrixMp, 
    range(self.numPixels), 
    workers=poolCount, 
    maxsize=2,
)

# iterate over it in the main process
for x in stage:
   # code

# or convert it to a list
data = list(stage)
Discussions

Doubts about Multiprocessing.Pool() class arguments
Good afternoon to everyone. My name is Joan, this is my first message within the Python community and I would like to ask you some doubts about the meaning of two of the arguments from the Pool class: “processes” and “maxtasksperchild”. “processes”. As far as I’m concerned, this ... More on discuss.python.org
🌐 discuss.python.org
8
0
February 16, 2022
WHY does multiprocessing not work properly in `__main__.py`
The following is the first example in “multiprociessing” page of Python doc. from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': with Pool(5) as p: print(p.map(f, [1, 2, 3])) I have a project root with directory: foo -- __main__.py -- file.py Copy paste the ... More on discuss.python.org
🌐 discuss.python.org
2
0
November 7, 2022
A shared object in multiprocessing
There is a shared object that I need to pass to multiprocessing workers in a Pool. It has two properties: (1) it cannot be serialized such that it has to be initialized from scratch in each worker separately and (2) its instantiation takes a very long time. I would like to instantiate the object ... More on discuss.python.org
🌐 discuss.python.org
6
0
May 16, 2025
multiprocess.Process vs. multiprocess.Pool
BTW Python version 2.7, os = Linux More on reddit.com
🌐 r/learnpython
3
8
March 27, 2013
🌐
Reddit
reddit.com › r/python › python multiprocessing pool: complete api guide
r/Python on Reddit: Python Multiprocessing Pool: Complete API Guide
November 23, 2023 - Any ideas on how I can have a process pool but the processes are custom processes instead of generic ones? Kinda like how we can make custom processes by overriding multiprocessing.Process?
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-multiprocessing-example
Python Multiprocessing Example: Process, Pool & Queue | DigitalOcean
March 31, 2026 - Learn Python multiprocessing with hands-on examples covering Process, Pool, Queue, and starmap. Run code in parallel today with this tutorial.
🌐
GeeksforGeeks
geeksforgeeks.org › python › synchronization-pooling-processes-python
Synchronization and Pooling of processes in Python - GeeksforGeeks
September 15, 2023 - In order to utilize all the cores, multiprocessing module provides a Pool class. The Pool class represents a pool of worker processes. It has methods which allows tasks to be offloaded to the worker processes in a few different ways.
Find elsewhere
🌐
Real Python
realpython.com › ref › stdlib › multiprocessing
multiprocessing | Python Standard Library – Real Python
Supports local concurrency and remote concurrency with multiprocessing.managers and explicit setups · Offers process pools for simple parallel task management · Provides shared data structures such as queues and pipes · Starts workers with the spawn, fork, or forkserver start method, defaulting as of Python 3.14 to forkserver on Unix platforms other than macOS and to spawn on macOS and Windows, so fork is no longer the default on any platform ·
🌐
PyPI
pypi.org › project › multiprocess
multiprocess · PyPI
>>> from multiprocess import Pool >>> def f(x): return x*x ...
🌐
Emergys
emergys.com › home › blog › python multiprocessing: pool vs process – comparative analysis
Python Multiprocessing: Pool vs Process – Comparative Analysis | Emergys
April 3, 2021 - To summarize this, pool class works better when there are more processes and a small IO wait. Process class works better when methods are small in number and IO operations are extended. What was your experience with Python Multiprocessing?
🌐
Python.org
discuss.python.org › python help
Doubts about Multiprocessing.Pool() class arguments - Python Help - Discussions on Python.org
February 16, 2022 - Good afternoon to everyone. My name is Joan, this is my first message within the Python community and I would like to ask you some doubts about the meaning of two of the arguments from the Pool class: “processes” and “maxtasksperchild”. “processes”. As far as I’m concerned, this argument lets the user introduce the number of processors (cores from a CPU) in which the different processes will divide.
🌐
StrataScratch
stratascratch.com › blog › how-to-use-python-multiprocessing
How to Use Python Multiprocessing for Better Performance - StrataScratch
January 8, 2026 - We first define a function that reads a small tuple, then finish with an if block that passes these items to a pool. Here is the code. from multiprocessing import Pool def process_item(item): name, value = item return value * 2 if __name__ == "__main__": items = [("a", 10), ("b", 20), ("c", 30)] with Pool() as pool: print(pool.map(process_item, items))
🌐
Medium
medium.com › @mehta.kavisha › different-methods-of-multiprocessing-in-python-70eb4009a990
Different Methods of Multiprocessing in Python | by KAVISHA MEHTA | Medium
December 10, 2022 - Each process needs to be created explicitly and hence makes it user-managed/program-managed. A process pool is a programming pattern for automatically managing a pool of worker processes.
🌐
Kyle M. Douglass
kmdouglass.github.io › posts › learning-pythons-multiprocessing-module
Learning Python's Multiprocessing Module | Kyle M. Douglass
December 29, 2014 - A very important thing to note is that the arguments must be objects that can be pickled using Python's pickle module. If an argument is a class instance, this means that every attritube of that class must be pickleable. An important class in the multiprocessing module is a Pool.
🌐
Medium
martinxpn.medium.com › thread-pools-and-process-pools-in-python-75-100-days-of-python-4101f10f64fc
Thread Pools and Process Pools in Python (75/100 Days of Python) | by Martin Mirakyan | Medium
April 10, 2023 - Python has a built-in multiprocessing module that allows you to create and manage processes. To use multiprocessing pools in Python, you can use the Pool class from the multiprocessing module.
🌐
SingularityKChen
singularitykchen.github.io › blog › 2021 › 03 › 05 › Code-Study-Python-multiprocessing
[CodeStudy] Python Multiprocessing with Return Values Using Pool | SingularityKChen
March 5, 2021 - In Python, you can use Process class to get child process, but seems you need to manage them manually. In my case, there is a class called Pool which represents a pool of worker processes and I can simply manage the child process and receive the return values. from multiprocessing import Pool import time def test(p): print(p) time.sleep(3) if __name__=="__main__": pool = Pool(processes=2) for i in range(500): pool.apply_async(func=test, args=(i,)) print('test') pool.close() pool.join()
🌐
InterServer
interserver.net › home › python › understanding multi-processing in python: a simiplified guide
Understanding Multi-Processing in Python: A Simiplified Guide - Interserver Tips
April 24, 2026 - The pool concept in Python multiprocessing is useful when you have a set of independent tasks that can be executed concurrently.
🌐
Python.org
discuss.python.org › python help
WHY does multiprocessing not work properly in `__main__.py` - Python Help - Discussions on Python.org
November 7, 2022 - The following is the first example in “multiprociessing” page of Python doc. from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': with Pool(5) as p: print(p.map(f, [1, 2, 3])) I have a project root with directory: foo -- __main__.py -- file.py Copy paste the above example code into each file.
🌐
Medium
medium.com › @AlexanderObregon › understanding-pythons-multiprocessing-module-744dba8d4be4
Understanding Python’s Multiprocessing Module | Medium
August 10, 2024 - Managing concurrent tasks efficiently is a key aspect of leveraging Python’s multiprocessing module. It provides the Pool class to facilitate the parallel execution of a function across multiple input values, thus enabling you to distribute ...
🌐
Sebastian Raschka
sebastianraschka.com › home › an introduction to parallel programming using python's multiprocessing module
An introduction to parallel programming using Python’s multiprocessing module
February 5, 2026 - Parallel programming in Python with multiprocessing: bypassing the GIL, spawning processes, using Pool.map, and speeding up CPU-bound workloads.
🌐
Python.org
discuss.python.org › python help
A shared object in multiprocessing - Python Help - Discussions on Python.org
May 16, 2025 - There is a shared object that I need to pass to multiprocessing workers in a Pool. It has two properties: (1) it cannot be serialized such that it has to be initialized from scratch in each worker separately and (2) its …