-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use reverse iteration protocol in mapfoldr_impl
#24833
Conversation
8ab1dc8
to
975443f
Compare
@@ -96,16 +96,16 @@ foldl(op, itr) = mapfoldl(identity, op, itr) | |||
|
|||
## foldr & mapfoldr | |||
|
|||
function mapfoldr_impl(f, op, v0, itr, i::Integer) | |||
function mapfoldr_impl(f, op, v0, itr_r, i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this! I was wondering if there is any difference between mapreduce
and mapfoldr_impl
?
mapfoldr(f, op, v0, itr) = mapreduce(f, op, v0 , Iterators.reverse(itr))
should be equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two problems with this.
mapreduce
doesn't define its associativity — it is allowed to associate however it wants.- even if you use
mapfoldl
, you are assuming thatop
is commutative as well as associative.foldr
changes associativity, but does not commute operands.
Maybe add a test case for something that fails in 0.6, i.e. for an iterator that is reversible but not indexable. For example, @test foldr(Pair, 0, Iterators.filter(iseven, 1:6)) === foldr(Pair, 0, 2:2:6) === (2=>(4=>(6=>0))) |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
The performance regressions reported by Nanosoldier can't possibly be real; they are in lots of functions (e.g. |
This noise level is nothing out of the ordinary. Benchmarks looks good to me. |
±45% noise, with ±25% on dozens of benchmarks, is far worse than it used to be. It makes nanosoldier almost useless except to catch truly enormous regressions. |
Why was this closed? |
Unclear. @YingboMa? |
Oops sorry, I thought that this PR wasn't planned to be merged. |
This PR addresses the issue #24823. I replace the
getindex
andendof
by the reverse iteration protocol in the functionmapfoldr_impl
.