-
Notifications
You must be signed in to change notification settings - Fork 17
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
iterate
fallback causes 5X performance drop
#45
Comments
Might be due to #46, where many trivial operations become non-trivial in the fallback solutions. Mind to submit a PR? |
Sorry, I was not clear in the previous comment; the solution you proposed seems to be a good patch already for this specific issue, PR is welcomed for this. The root cause might be #46 but that's pretty much difficult to find a generic solution, as you have noted. I don't have a good solution to that, neither. |
Any suggestions on what to do with the "Multi" types? |
If I understand it correctly, the iterate protocol returns |
Consider a "function" that has two versions.
foo3
is justfoo2
, but it accepts a function in the first argument the same way that e.g.sum
does.I personally do not like the pattern, and
MappedArrays.jl
gives me a way of factoring out that function so that I can only writefoo2
, even if I, say, need to do the computation only on a specific field of each element.But the performance is not equivalent:
The fallback on
iterate(::AbstractArray, ...)
appears to be responsible. Definingeliminates the gap!
Defining
iterate
onMappedArray
is straightforward, too. I'm not sure what to do for the "Multi" types.(originally from https://github.com/goretkin/FactorPerElementFunctionPerformance and https://discourse.julialang.org/t/factor-out-field-access-of-abstractarray-and-or-iterator-interface/41493)
The text was updated successfully, but these errors were encountered: