Concurrent Processing


from concurrent import futures

Create Data

data = range(100)

Create Function

# Create some function that takes a value
def some_function(value):
    # And outputs it raised to its own power
    return value**value

Run The Function On The Data Concurrently

# With a pool of workers
with futures.ProcessPoolExecutor() as executor:
    # Map the function to the data
    result =, data)

View Results

# List the first 5 outputs
[1, 1, 4, 27, 256]