Skip to content

VarNamedTuple #900

Open
Open
@penelopeysm

Description

@penelopeysm

A fundamental 'problem' in DynamicPPL is the choice between NamedTuple and Dict. For example, ConditionContext and FixedContext can be instantiated with both. There is also the entirety of the typed VarInfo data structure which is heavily influenced by this.

The main benefit of NamedTuple is type stability, which is accomplished through the use of macros and/or generated functions. The main drawback of NamedTuple is the inability to represent VarNames with a non-identity optic (e.g. @varname(x[1]), @varname(x.a)) correctly. The pros and cons of Dict are the opposite.

It would be very nice if we could make a new data structure that combines the best of both worlds, i.e. represents a mapping from (possibly non-identity) VarNames to arbitrary data, but can be used in a type-stable (and reasonably performant) manner.

This would help to eliminate a bunch of things that sometimes work and sometimes don't.

It might also open up possibilities for further tidying up metadata / VNV data structures to ensure that information stays in sync.

I haven't investigated this concretely yet, but @mhauru and I have been mucking around with this idea for a while now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions