andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
283 stars 28 forks source link

Enabling dynamic and fixed indices. #5

Open Tokazama opened 4 years ago

Tokazama commented 4 years ago

This came up on discourse. It's pretty important to have indices that are mutable for a lot of things methods to work (append!, push!, etc.), but there are times it's worth improving performance and losing mutating functions. I mentioned my work on StaticRanges.jl may be helpful. It provides mutable ranges as well with protective setproperty! methods so that users don't accidently make bizarre changes to a mutable range.

This could be as simple as:

const StaticIndicesRange{T,L} = Indices{T,OneToSRange{T,L}}
const DynamicIndicesRange{T} = Indices{T,OneToMRange{T}}
const FixedIndicesRange{T} = Indices{T,OneTo{T}}

If this is something you're interested in I'd be interested in further discussing how to implement it.

andyferris commented 4 years ago

Yes, once some ordering semantics of AbstractDictionary are resolved in #13 I don't see why we can't have array-like dictionaries with ranges as keys.

I don't think implementing this will be too hard - e.g. Indices can have tokens and lookup can defer to findfirst for AbstractArrays, we can set the issettable and isinsertable traits accordingly, or something like that... hmm...

Tokazama commented 4 years ago

I'd ultimately like to incorporate this package into AxisIndices.jl so once #13 is in place I'd be happy to help out with the details of this.