Skip to content

Add traverse kwarg to delayed#1899

Merged
jcrist merged 3 commits intodask:masterfrom
jcrist:traverse_false
Jan 10, 2017
Merged

Add traverse kwarg to delayed#1899
jcrist merged 3 commits intodask:masterfrom
jcrist:traverse_false

Conversation

@jcrist
Copy link
Copy Markdown
Member

@jcrist jcrist commented Jan 9, 2017

By default dask traverses builtin python collections looking for dask
objects passed to delayed. For large collections this can be
expensive. This PR adds a keyword traverse to delayed, to tell
dask to avoid doing this traversal.

Fixes #1884.

By default dask traverses builtin python collections looking for dask
objects passed to ``delayed``. For large collections this can be
expensive. This PR adds a keyword ``traverse`` to ``delayed``, to tell
dask to avoid doing this traversal.

Fixes dask#1884.
task, dasks = to_task_dasks(obj)
else:
task = quote(obj)
dasks = []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why the need to quote?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If obj is a tuple that looks like a task, or a list containing tuples that look like tasks. Looks like the second isn't handled though, will fix.

Previously `quote` would only quote tasks, and would make a copy of the
tuple, as well as recurse into its arguments. Now we wrap literals in a
small class, and then return a task to unbox them. This is more
efficient, as it removes the need to copy and is O(1) (instead of
recursing through the collection).
@jcrist
Copy link
Copy Markdown
Member Author

jcrist commented Jan 9, 2017

Should be good to go now.

@jcrist
Copy link
Copy Markdown
Member Author

jcrist commented Jan 10, 2017

Merging soon if no comment.

Use `__call__` instead of a separate function.
@jcrist jcrist merged commit b2dbc97 into dask:master Jan 10, 2017
@jcrist jcrist deleted the traverse_false branch January 10, 2017 19:20
@sinhrks sinhrks added this to the 0.14.0 milestone Mar 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants