Hi everyone! ![]()
I’d like to announce the StaticDictTrees.jl package. It provides a high-performance dictionary with Tuples as keys, and with the added functionality of providing views into any data subset identified by an incomplete key.
If you’ve ever used a Dict{Tuple, T} and wished you could instantly isolate all entries sharing a specific prefix without an expensive O(N) filter, this package is for you.
An example is worth a million words:
using StaticDictTrees
# Create a static dict tree
metrics = SDTree((:prod, :web, :cpu) => 42.5,
(:prod, :web, :ram) => 78.1,
(:prod, :db, :cpu) => 12.0,
(:stage, :web, :cpu) => 8.4)
# Standard full-key lookup
metrics[:prod, :web, :cpu] # 42.5
# Take a zero-allocation, type-stable view of a sub-branch
prod_web = view(metrics, (:prod, :web))
# The view behaves exactly like a relative AbstractDict ...
prod_web[:ram] # 78.1
# ... and any modification in a view is reflected in the original tree
prod_web[:ram] = 99.
metrics[:prod, :web, :ram] # 99.
Comments are welcome!