You could also use TypeSortedCollections.jl for this (I’m the author). It basically automates your createconcretecollection
/sumconcretecollection
approach:
julia> using TypeSortedCollections
julia> tsc = TypeSortedCollection(createabstractcollection());
julia> @btime mapreduce(value, +, 0, $tsc)
1.204 ms (0 allocations: 0 bytes)
500001499788