50 Commits

Author SHA1 Message Date
Raymond Hettinger
ab294199b7 Teach set modules to correctly compute s-=s and s^=s as the empty set. 2005-08-13 02:28:54 +00:00
Raymond Hettinger
70b9f499a3 Remove deprecation of sets.Set.update(). 2003-11-19 15:52:14 +00:00
Raymond Hettinger
859db26729 Improve backwards compatibility code to handle True/False. 2003-11-12 15:21:20 +00:00
Raymond Hettinger
9d50d91e77 Set the warnings stacklevel to two. 2003-09-08 19:16:36 +00:00
Raymond Hettinger
6a1801271a Improvements to set.py:
* Relaxed the argument restrictions for non-operator methods.  They now
  allow any iterable instead of requiring a set.  This makes the module
  a little easier to use and paves the way for an efficient C
  implementation which can take better advantage of iterable arguments
  while screening out immutables.

* Deprecated Set.update() because it now duplicates Set.union_update()

* Adapted the tests and docs to include the above changes.

* Added more test coverage including testing identities and checking
  to make sure non-restartable generators work as arguments.

Will backport to Py2.3.1 so that the interface remains consistent
across versions.  The deprecation of update() will be changed to
a FutureWarning.
2003-08-17 08:34:09 +00:00
Raymond Hettinger
ee562fc084 Make sets.py compatible with Py2.2 2003-08-15 21:17:04 +00:00
Raymond Hettinger
f6fe4eda6e Portion of SF patch #761104. Fixes a minor docstring error.
_TemporarilyImmutableSet is in fact a subclass of BaseSet
2003-06-26 18:49:28 +00:00
Tim Peters
44f14b0399 SF bug 693121: Set == non-Set is a TypeError.
Allow mixed-type __eq__ and __ne__ for Set objects.  This is messier than
I'd like because Set *also* implements __cmp__.  I know of one glitch now:
cmp(s, t) returns 0 now when s and t are both Sets and s == t, despite
that Set.__cmp__ unconditionally raises TypeError (and by intent).  The
rub is that __eq__ gets tried first, and the x.__eq__(y) True result
convinces Python that cmp(x, y) is 0 without even calling Set.__cmp__.
2003-03-02 00:19:49 +00:00
Raymond Hettinger
2835e37be5 SF bug #663701: sets module review
Renamed hook methods to use the double underscore convention.
2003-02-14 03:42:11 +00:00
Raymond Hettinger
60eca9331a C Code:
* Removed the ifilter flag wart by splitting it into two simpler functions.
* Fixed comment tabbing in C code.
* Factored module start-up code into a loop.

Documentation:
* Re-wrote introduction.
* Addede examples for quantifiers.
* Simplified python equivalent for islice().
* Documented split of ifilter().

Sets.py:
* Replace old ifilter() usage with new.
2003-02-09 06:40:58 +00:00
Tim Peters
322d553143 Whitespace normalization. 2003-02-04 00:38:20 +00:00
Raymond Hettinger
1ecfb73c26 One more use of ifilter() 2003-02-02 16:07:53 +00:00
Raymond Hettinger
a3a53180c0 SF patch #678899: Save time and memory by using itertools in sets module. 2003-02-02 14:27:19 +00:00
Guido van Rossum
50e92235e7 Explicitly raise an exception in __cmp__ -- this clarifies that cmp()
is not supported on sets.  (Unfortunately, sorting a list of sets may
still return random results because it uses < exclusively, but for
sets that inly implements a partial ordering.  Oh well.)
2003-01-14 16:45:04 +00:00
Raymond Hettinger
35e48d2426 SF 643115: Set._update() had a special case for dictionaries which allowed
non-true values to leak in.  This threw-off equality testing which depends
on the underlying dictionaries having both the same keys and values.
2002-11-25 20:43:55 +00:00
Jeremy Hylton
cd58b8f532 Add getstate and setstate implementation to concrete set classes. 2002-11-13 19:34:26 +00:00
Guido van Rossum
7cd83ca9ad Another attempt at making the set constructor both safe and fast. [SF
bug 628246]
2002-11-08 17:03:36 +00:00
Tim Peters
0ec1ddcdcf _update(): Commented the new obscurity. Materialized into a tuple
instead of into a list for a bit of speed/space savings.  Reopened the
bug report too (628246), as I'm unclear on why we don't sort out the
cause of the TypeError instead.
2002-11-08 05:26:52 +00:00
Raymond Hettinger
1eb1fb814b Closes SF bug #628246.
The _update method detected mutable elements by trapping TypeErrors.
Unfortunately, this masked useful TypeErrors raised by the iterable
itself.  For cases where it is possible for an iterable to raise
a TypeError, the iterable is pre-converted to a list outside the
try/except so that any TypeErrors propagate through.
2002-11-08 05:03:21 +00:00
Raymond Hettinger
bfcdb8734e .iterkeys() is not needed. 2002-10-04 20:01:48 +00:00
Raymond Hettinger
1a8d193121 Sped _update().
Uses the fast update() method when a dictionary is available.
2002-08-29 15:13:50 +00:00
Tim Peters
454602f0f7 Gave intersection_update a speed boost. 2002-08-26 00:44:07 +00:00
Tim Peters
cd06eeb20c Gave issubet() and issuperset() major speed boosts. That's it for now!
Someone else may want to tackle the mutating operations similarly.
2002-08-25 20:12:19 +00:00
Tim Peters
b8940393e9 Gave __sub__/difference a factor of 2-5 speed boost. 2002-08-25 19:50:43 +00:00
Tim Peters
334b4a5c39 Gave __xor__/symmetric_difference a factor of 2-5 speed boost. 2002-08-25 19:47:54 +00:00