Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: feature-gated rayon integration for itertools #271

Open
dbkaplun opened this issue Apr 8, 2018 · 2 comments
Open

Feature: feature-gated rayon integration for itertools #271

dbkaplun opened this issue Apr 8, 2018 · 2 comments

Comments

@dbkaplun
Copy link

dbkaplun commented Apr 8, 2018

Hello,

It would be great if itertools and rayon could work with each other. This would be very useful for gradually improving itertools-based code to work with rayon's parallel iteration.

Why not use rayon's existing iteration helper methods?

  • Some existing code uses itertools. To parallelize it, one would have to remove the itertools-based parts to use rayon. In some cases rayon may not provide a good alternative to the powerful iteration methods afforded by itertools, like cartesian_product.

What this would entail:

  • From a high level, this would require an impl IntoParallelIterator for itertools::Itertools. That should be enough, from an end-user perspective. Itertools would then have a feature-gated .into_par_iter method callable whenever the rayon feature flag is enabled.
    Note that it may also be possible to provide an impl for ParallelIterator directly so that rayon methods and itertools methods can be interspersed.

Providing an interface between rayon and itertools would be beneficial for parallelizing any existing code based on itertools, as well as reducing friction between complementary iterator tools.

Is this something you'd like to see? Would you be willing to accept a Pull Request adding this functionality?

Thanks for considering!

@rohitjoshi
Copy link

Looking forward to this feature. I am currently using rayon iterator for ziping two arrays. Trying to zip multiple arrays and combination of rayon and itertool will definitely help.

@cuviper
Copy link
Contributor

cuviper commented Apr 20, 2018

From a high level, this would require an impl IntoParallelIterator for itertools::Itertools.

I think this would be served by the long-standing rayon request for Iterator support, rayon-rs/rayon#46, and we may have a way forward in rayon-rs/rayon#550. I'm not sure there's much that itertools could do in particular that couldn't be more broadly applicable, especially since all of these adaptors have to deal with generic Iterator inputs themselves.

On the rayon side, we've already tried to provide equivalents to many itertools methods -- at least those where the semantics of a parallel translation are straightforward.

@dbkaplun dbkaplun changed the title Feature request: feature-gated rayon integration for itertools Feature: feature-gated rayon integration for itertools May 4, 2018
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

No branches or pull requests

3 participants