-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentationfoldsum, maximum, reduce, foldl, etc.sum, maximum, reduce, foldl, etc.sparseSparse arraysSparse arrays
Description
This is split out from #53945 (comment):
Both map
and mapreduce
sometimes re-use return values — most notably with sparse data structures. map
's docs don't mention this, whereas mapreduce
explicitly allows for it — but neither documentation is ideal. It'd be nice to more finely scope this behavior along the lines of @MasonProtter's comment:
I think it's a sensible corner case to make it clear to people that we're not normally in the buisness of memoizing reductions, but if a datastructure has its own memoization scheme then we'll reserve the right to also take advantage of that.
There are probably more functions like these — including broadcast — that'd be good to evaluate at the same time.
julia> using SparseArrays
julia> map(x->x+rand(), spzeros(3))
3-element SparseVector{Float64, Int64} with 3 stored entries:
[1] = 0.538611
[2] = 0.538611
[3] = 0.538611
julia> broadcast(x->x+rand(), spzeros(3))
3-element SparseVector{Float64, Int64} with 3 stored entries:
[1] = 0.983621
[2] = 0.983621
[3] = 0.983621
Metadata
Metadata
Assignees
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentationfoldsum, maximum, reduce, foldl, etc.sum, maximum, reduce, foldl, etc.sparseSparse arraysSparse arrays