ordered-set
ordered-set copied to clipboard
Treat hashables
Any hashable may be added to a set (OrderedSet). Hashables are sometime iterables (tuple, frozenset, string). As soon as OrderedSet.index treats iterables differently compared to the way list works, it should be protected against iterating over hashables. Before, only protection for strings and tuples did exist. In this comment a general approach for any hashable is added. Relevant unit test is added. Documentation is updated.
Also, add slots as slots make it more efficient to access object attributes. It also forbids assigning non-existing attributes, which is consistent with other basic classes, e.g. list, tuple, dict.