I keep needing one, so I wrote it.
If you have:
```rust
asserteq!(
(0..10)
.map(stepa)
.filter(filterb)
.map(stepc).collect::
You can change it to:
```rust use dpc_pariter::IteratorExt;
asserteq!(
(0..10)
.map(stepa)
.filter(filterb)
.parallelmap(step_c).collect::
and it will run faster (conditions apply), because
step_c
will run in parallel on multiple-threads.
Or you can try even more features:
```rust use dpc_pariter::IteratorExt;
asserteq!(
(0..10)
.map(stepa)
.readahead(0)
.parallelfilter(filterb)
.parallelmap(stepc).collect::
This library is a good general purpose solution. When you have a chain of iterator steps, and would like to process one or some of them in parallel to speed it up, this should be a drop-in replacement.
Sending iterator items through channels is fast, but not free. Make sure to parallelize operations that are heavy enough to justify overhead of sending data through channels. E.g. operations involving IO or some CPU-heavy computation.
When you have a lot items already stored in a collection,
that you want to "roll over and perform some mass computation"
you probably want to use rayon
instead. It's a library optimized
for parallelizing processing of whole chunks of larger set of data.
Because of that converting rayon
's iterators back to ordered
sequencial iterator is non-trivial.
There are alternative libraries somewhat like this, but I did not find any that I'd like API and/or implementation wise, so I wrote my own.
I keep needing this exact functionality, so I've cleaned up my ad-hoc code and put it in a proper library. I would actually prefer if someone else did it. :D I might add more features in the future, and I am happy to accept PRs.
I'm open to share ownership & maintenance, or even "donate it".