This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aleax
Recipients
Date 2002-07-13.15:53:44
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
As per python-dev discussion on Sat 13 July 2002, 
subject
"Dict constructor".  A version of Greg Wilson's sandbox
Set class that avoids the trickiness of implicitly freezing
a set when __hash__ is called on it.  Rather, uses 
several classes: Set itself has no __hash__ and 
represents a
general, mutable set; BaseSet, its superclass, has all
functionality common to mutable and immutable sets; 
ImmutableSet also subclasses BaseSet and adds 
__hash__; a wrapper _TemporarilyImmutableSet wraps
a Set exposing only __hash__ (identical to that an 
ImmutableSet built from the Set would have) and __eq__ 
and __ne__ (delegated to the Set instance).

Set.add(self, x) attempts to call x=x._asImmutable() (if
AttributeError leaves x alone); Set._asImmutable(self)
returns ImmutableSet(self).
Membership test BaseSet.__contains__(self, x) attempt
to call x = x._asTemporarilyImmutable() (if AttributeError 
leaves x alone); Set._asTemporarilyImmutable(self) 
returns TemporarilyImmutableSet(self).

I've left Greg's code mostly alone otherwise except for
fixing bugs/obsolescent usage (e.g. dictionary rather than
dict) and making what were ValueError into TypeError 
(ValueError was doubtful earlier, is untenable now that
mutable and immutable sets are different types).  The
change in exceptions forced me to change the unit tests
in test_set.py, too, but I made no other changes nor
additions.
History
Date User Action Args
2007-08-23 15:14:09adminlinkissue580995 messages
2007-08-23 15:14:09admincreate