[Python-3000] sets in P3K?

Ron Adam rrr at ronadam.com
Fri Apr 28 19:27:14 CEST 2006


Jim Jewett wrote:
> On 4/28/06, Greg Wilson <gvwilson at cs.utoronto.ca> wrote:
>> - introduce '@' as a prefix operator meaning 'freeze'.
> 
> I mostly like the concept, but not the operator.  Using @ limits it to
> syntax-created literals (because of ambiguity with decorators).  Since
> numbers are already immutable, that basically means lists, dicts, and
> maybe sets, but not even user-defined subclasses.  (And you don't have
> to do it with tuples, because ... uh ...)  I'm not sure what to use
> instead, except maybe for the backwards quote, which means I have to
> duck now too.  ("frozen" or "snapshot" might be too long to be
> useful.)

How about the '!' which is currently used indicate a python long and an 
integer.  Here it would indicate the difference between a frozen 
container and a mutable container.

     frozen_set = {1, 2, 3}!
     frozen_dict = {1:'a', 2:'b', 3:'c'}!


> I am slightly concerned that it *might* be a bad idea to encourage
> immutable containers, in the same way that it can be a bad idea to
> prevent subclassing or even to use a __slots__ field.

We can always discourage something in the docs by giving reasons not to 
use that which isn't a good idea in the context for which it isn't a 
good idea.

Cheers,
    Ron



More information about the Python-3000 mailing list