dask 2021.10.0

ParametersBackRef
optimize(*args, **kwargs)

Returns equivalent dask collections that all share the same merged and optimized underlying graph. This can be useful if converting multiple collections to delayed objects, or to manually apply the optimizations at strategic points.

Note that in most cases you shouldn't need to call this method directly.

Parameters

*args : objects

Any number of objects. If a dask object, its graph is optimized and merged with all those of all other dask objects before returning an equivalent dask collection. Non-dask arguments are passed through unchanged.

traverse : bool, optional

By default dask traverses builtin python collections looking for dask objects passed to optimize . For large collections this can be expensive. If none of the arguments contain any dask objects, set traverse=False to avoid doing this traversal.

optimizations : list of callables, optional

Additional optimization passes to perform.

**kwargs :

Extra keyword arguments to forward to the optimization passes.

Optimize several dask collections at once.

Examples

This example is valid syntax, but we were not able to check execution
>>> import dask as d
... import dask.array as da
... a = da.arange(10, chunks=2).sum()
... b = da.arange(10, chunks=2).mean()
... a2, b2 = d.optimize(a, b)
This example is valid syntax, but we were not able to check execution
>>> a2.compute() == a.compute()
True
This example is valid syntax, but we were not able to check execution
>>> b2.compute() == b.compute()
True
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.base.optimize

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/base.py#457
type: <class 'function'>
Commit: