# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.7.4
#     language: python
#     name: python-374
# ---

# # IPython’s `Direct` interface

# ## Create a `DirectView`

import ipyparallel as ipp
rc = ipp.Client()

rc = ipp.Client(profile='default')

rc.ids

# Use all engines:

dview = rc[:]

# ## `map()` function
#
# Python’s builtin `map()` function can be applied to a sequence of elements and is usually easy to parallelise.
#
# Please note that the `DirectView` version of `map()` does not do automatic load balancing. You may have to use `LoadBalancedView` for this.

serial_result = list(map(lambda x:x**10, range(32)))

parallel_result = dview.map_sync(lambda x: x**10, range(32))

serial_result == parallel_result

StarcoderdataJupyterScriptsDedupFiltered