Should stored `Dict` nodes return a `frozendict`?

Currently, trying to change nested content of a stored Dict node fails silently:

In [3]: d = Dict({'a': {'b': None, 'c': None}})
   ...: d['a']['b'] = 2
   ...: print(d.get_dict())
{'a': {'b': 2, 'c': None}}

In [4]: d.store()
   ...: d['a']['c'] = 3
   ...: print(d.get_dict())
{'a': {'b': 2, 'c': None}}

See the corresponding issue for a more extensive description of this problem. This can be quite confusing for users, and potentially causes them to run calculations with unintended parameters.

One solution would be to have a stored Dict node return a frozendict:

As mentioned there, the PR is still a work in progress, but I already wanted to ask the AiiDA developer community if anyone sees any unintended consequences of this change that we should be wary of.

2 Likes