Skip to content

Instantly share code, notes, and snippets.

@robertnishihara
Created February 11, 2019 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertnishihara/1a5cbbc5f11b93708c9265d9df4fc27e to your computer and use it in GitHub Desktop.
Save robertnishihara/1a5cbbc5f11b93708c9265d9df4fc27e to your computer and use it in GitHub Desktop.
# Slow approach.
values = [1, 2, 3, 4, 5, 6, 7, 8]
while len(values) > 1:
values = [add.remote(values[0], values[1])] + values[2:]
result = ray.get(values[0])
# Fast approach.
values = [1, 2, 3, 4, 5, 6, 7, 8]
while len(values) > 1:
values = values[2:] + [add.remote(values[0], values[1])]
result = ray.get(values[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment