[Python-Dev] Re: PEP 218 (sets); moving set.py to Lib

Raymond Hettinger python@rcn.com
Thu, 29 Aug 2002 01:45:52 -0400


> 3.  Have ImmutableSet keep a reference to the original iterable.  Add an ImmutableSet.refresh() method that rebuilds ._data from
> the iterable.  Add a Set.refresh() method that triggers ImmutableSet.refresh() where possible.  The goal is to improve the
> usability of sets of sets where the inner sets have been updated after the outer set was created.
>
> >>> inner = Set('abracadabra')
> >>> outer = Set([inner])
> >>> inner.add('z')                 # now the outer set is out-of-date
> >>> outer.refresh()               # now it is current
> >>> outer
> Set(['a', 'c', 'r', 'z', 'b', 'd'])

Make that:

Set(ImmutableSet('a', 'c', 'r', 'z', 'b', 'd']))