[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    [Python-Dev] Re: PEP 218 (sets); moving set.py to Lib
From:       tim.one () comcast ! net (Tim Peters)
Date:       2002-08-29 16:21:38
Message-ID: BIEJKCLHCIOIHAGOKOLHIEOGDJAA.tim.one () comcast ! net
[Download RAW message or body]

[Raymond Hettinger]
> ...
> Hmm, I intended to have s1.refresh() return a new object for use
> in s2 while leaving s1 alone (being immutable and all).  Now, I
> wonder if that was the right thing to do.  The answer lies in use
> cases for algorithms that need sets of sets.  If anyone knows
> off the top of their head that would be great; otherwise, I seem
> to remember that some of that business was found in compiler
> algorithms and graph packages.

There's no real use case I know of for having a mutation of a set element
propagate to the set containing it.  Sets in Python are collections of
values, not collections of object ids (sets in Icon are collections of
object ids, and, e.g., Set([[], []]) in Icon is a set with two elements).
Value semantics darned near require copying, or fancier copy on write, under
the covers, and value semantics are most useful for sets of sets.  Once the
value has been established, you want to guarantee it never changes, not make
it easy to change it by accident <wink>.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic