I use a set
when I need to keep a reference list of values which I want to keep unique (and later on, check if something is in
that set
). This does not work with dict
because it is not hashable.
There are quite a few techniques to "uniquify" a list
of dict
but all of them assume that I have a final list
, which I want to reduce to unique elements.
How to do that in a dynamic way? For a set
I would just .add()
and element and would know that it will be added only if it is unique. Is such a (EDIT: ideally, but not necessarily) built-in mechanism available for a bag of dict
(I use the word "bag" because I do not want to limit possible answers to any data container)