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.
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.
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.
Additional optimization passes to perform.
Extra keyword arguments to forward to the optimization passes.
Optimize several dask collections at once.
>>> import dask as dThis example is valid syntax, but we were not able to check execution
... 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)
>>> a2.compute() == a.compute() TrueThis example is valid syntax, but we were not able to check execution
>>> b2.compute() == b.compute() TrueSee :
The following pages refer to to this document either explicitly or contain code examples using this.
dask.base.optimize
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