ANN: set-0.2 module available

Denis S. Otkidach ods at fep.ru
Tue May 21 06:15:11 EDT 2002


On 17 May 2002, Coady wrote:

C> -  The set hashing function is no longer brain-dead.  Thanks
C> to Kevin
C> Jacobs.
C> -  Set comparison has been better optimized.
C> -  Sets have two new (read&write) boolean attributes:
C> 'mutable' and
C> 'hashable'.  At the risk of feature bloat, this should allow
C> complete
C> flexibility.  The default is still the same:  hashable and
C> mutable,
C> but becomes immutable upon first (successful) hashing.

I guess mutable/hashable attributes are not useful.

Here is another problem:
>>> from set import set
>>> s=set((1,3,5))
>>> hash(s)
1272199707
>>> s&=set((2,4,6))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: set has become immutable

If the set became immutable it should not be modified in-place,
but &= operator should create new object according to ?=
documentation.  Unfortunately, it makes this error prone "2 in 1"
solution even more hard to debug.






More information about the Python-list mailing list