You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement OrderedSet by ourselves here in returnn-common.
Such implementation could use dict (due to Make minimum Python version explicit #43, no need for OrderedDict). Note that set does not a deterministic order in contrast to dict (since Python 3.6).
Implement it by ourselves in RETURNN (returnn.util.ordered_set or so) and use it here.
Use some external dependency (should be recent and used by many people):
(Others seem to be much less used, e.g. this or here. Or you know about common other ones?)
Suggestions? Opinions?
Another aspect, not really relevant for my use case currently, but maybe it will be: __eq__ is usually different on OrderedDict (and also Boltons IndexedSet) than it is on dict.__eq__/set.__eq__ and defines it such that it is only equal when it also has the same order. I see also use cases where we want to keep the original dict.__eq__/set.__eq__ logic.
The text was updated successfully, but these errors were encountered:
In 75948c8 I implemented now the variant via dict by not using set at all. And this is enough now for me. Maybe we can reopen this once we need it again for some other purpose.
For some internal handling (storing the
parents
of a module), I need a ordered set to make the behavior deterministic.Python does not have this as a builtin.
So our options:
dict
instead, with dummy values. (And then due to Make minimum Python version explicit #43 it is ordered.)OrderedSet
by ourselves here in returnn-common.dict
(due to Make minimum Python version explicit #43, no need forOrderedDict
). Note thatset
does not a deterministic order in contrast todict
(since Python 3.6).returnn.util.ordered_set
or so) and use it here.IndexedSet
Suggestions? Opinions?
Another aspect, not really relevant for my use case currently, but maybe it will be:
__eq__
is usually different onOrderedDict
(and also BoltonsIndexedSet
) than it is ondict.__eq__
/set.__eq__
and defines it such that it is only equal when it also has the same order. I see also use cases where we want to keep the originaldict.__eq__
/set.__eq__
logic.The text was updated successfully, but these errors were encountered: