On Thursday, April 14, 2016 11:54:45 AM James Fairbanks wrote: > function SparseArray(data, dims) > nt, t = eltype(data).types > n = length(nt.types) > C = typeof(data) > return SparseArray{t, n, C}(data, dims) > end
As you feared, using .types this way messes up inference. The better approach is SparseArray{K,V,N}(data::Associative{K,V}, dims::NTuple{N,Int}) = SparseArray{V, N, typeof(data)}(data, dims) Your 1D constructor could just dispatch to this with SparseArray(data, (dims,)) If you add @inline in front of the getindex/setindex! functions, you may be able to eliminate the splatting penalty, and you won't need the 1D specializations. Best, --Tim