1. 21 Agu, 2002 7 kayıt (commit)
    • Raymond Hettinger's avatar
    • Raymond Hettinger's avatar
      Replace all cases of "while 1" with "while True". · a6e16a86
      Raymond Hettinger yazdı
      Though slightly slower, has better clarity and teaching value.
      a6e16a86
    • Raymond Hettinger's avatar
    • Guido van Rossum's avatar
      Ouch. The test suite *really* needs work!!!!! There were several · 9f87293b
      Guido van Rossum yazdı
      superficial errors and one deep one that aren't currently caught.  I'm
      headed for bed after this checkin.
      
      - Fixed several typos introduced by Raymond Hettinger (through
        cut-n-paste from my template): it's _as_temporarily_immutable, not
        _as_temporary_immutable, and moreover when the element is added, we
        should use _as_immutable.
      
      - Made the seq argument to ImmutableSet.__init__ optional, so we can
        write ImmutableSet() to create an immutable empty set.
      
      - Rename the seq argument to Set and ImmutableSet to iterable.
      
      - Add a Set.__hash__ method that raises a TypeError.  We inherit a
        default __hash__ implementation from object, and we don't want that.
        We can then catch this in update(), so that
        e.g. s.update([Set([1])]) will transform the Set([1]) to
        ImmutableSet([1]).
      
      - Added the dance to catch TypeError and try _as_immutable in the
        constructors too (by calling _update()).  This is needed so that
        Set([Set([1])]) is correctly interpreted as
        Set([ImmutableSet([1])]).  (I was puzzled by a side effect of this
        and the inherited __hash__ when comparing two sets of sets while
        testing different powerset implementations: the Set element passed
        to a Set constructor wasn't transformed to an ImmutableSet, and then
        the dictionary didn't believe the Set found in one dict it was the
        same as ImmutableSet in the other, because the hashes were
        different.)
      
      - Refactored Set.update() and both __init__() methods; moved the body
        of update() into BaseSet as _update(), and call this from __init__()
        and update().
      
      - Changed the NotImplementedError in BaseSet.__init__ to TypeError,
        both for consistency with basestring() and because we have to use
        TypeError when denying Set.__hash__.  Together those provide
        sufficient evidence that an unimplemented method needs to raise
        TypeError.
      9f87293b
    • Guido van Rossum's avatar
      Add Raymond H to the list of authors; add some XXX comments about · 26588222
      Guido van Rossum yazdı
      possible API improvements.
      26588222
    • Raymond Hettinger's avatar
      43db0d6a
    • Raymond Hettinger's avatar
      Optimize try/except ordering in sets.py. · de6d6979
      Raymond Hettinger yazdı
      Gains a 5:1 speed-up for membership testing by
      handling the most common case first (the case
      where the element is hashable).
      
      Closes SF Patch 597444.
      de6d6979
  2. 20 Agu, 2002 19 kayıt (commit)
  3. 19 Agu, 2002 14 kayıt (commit)