MetaGraphs.jl icon indicating copy to clipboard operation
MetaGraphs.jl copied to clipboard

Replace inner metadata Dicts with named tuples

Open sbromberger opened this issue 5 years ago • 4 comments

sbromberger avatar Aug 21 '18 19:08 sbromberger

If we add a new property, does it mean we reset the NamedTuple with a new one? NamedTuples are immutable

matbesancon avatar May 19 '19 13:05 matbesancon

So every vertex/edge could possibly then have a NamedTuple of different type, right? That could possibly be a problem with Julia having to specialize on every type.

Also NamedTuples are ordered and dictionaries are not, so there also another difference.

simonschoelly avatar May 19 '19 14:05 simonschoelly

Yes it would be ok if you store them as Vector{NamedTuple}.

Also NamedTuples are ordered and dictionaries are not, so there also another difference.

Not sure this would change much

matbesancon avatar May 19 '19 17:05 matbesancon

But if you then have a function

function f(t::NamedTuple) begin
    ... do something
end

where you pass the named tuple, then I thing the compiler might specialize the code for every different tuple type. I think that could be avoided by using the @nospecialize macro. But in any case, it would probably be the best then, if the user never has direct access to that named tuple.

I wonder if it would not be better to use some kind of dictionary here, that is specialized on having only a small number of keys.

simonschoelly avatar May 19 '19 17:05 simonschoelly