>> while i'm on the topic of sets, is the Set class intended to be immutable?
>
> No.   The builtin Python set type isn't immutable, so it doesn't
> seem sensible to make the SAGE one immutable.  E.g., the
> builtin set type has an add method:

ok, but there is no add method in the SAGE Set, nor is there a remove 
method. so as it stand right now, it isn't very similar to a python set.

> Sets in SAGE should have very similar behavior to Python sets,
> except "be more mathematical", and of course allow for infinite
> sets.  Thus actually, regarding your previous patch, sets shouldn't
> be allowed as dictionary keys and shouldn't have a hash method
> at all, or have one that raises type error.  If you want to use one
> as a key, you should maybe be using a tuple instead.

if Sets aren't going to be usable as dictionary keys, then i'm going to 
create a new immutable set class that can, because i really need that. 
tuples won't cut it.

> I would not be opposed to creating an immutability flag
> for sets, and having a "set_immutable" option (like with
> Sequences), to create immutable sets.  But those shouldn't
> be the default.

you mean something like

     s = Set([1,2,3],immutable=True)

? that would work for me. in any case, i think the following behaviour

>>
>> In [58]: x=[1,2,3]
>>
>> In [59]: s=Set(x)
>>
>> In [60]: x[1]=5
>>
>> In [61]: s
>> Out[61]: {1, 3, 5}


is still highly undesirable.

shall i go ahead and add the immutable option, and some add and remove 
methods?

-kyle


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to