35 Commits

Author SHA1 Message Date
Georg Brandl
66e75ac6e0 Disallow keyword arguments for type constructors that don't use them
(fixes #1119418).
2005-08-26 06:43:16 +00:00
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
787b4c5fea * SF bug #1257731: Fix logic in set.__contains__(), set.remove(),
and set.discard for handling keys that both inherite from set and
  define their own __hash__() function.

* Fixed O(n) performance issue with set.pop() which should have been
  an O(1) process.
2005-08-12 23:47:50 +00:00
Raymond Hettinger
8f7dce605f SF patch #1200018: Restore GC support to set objects
Reverts 1.26 and 1.27.
And adds cycle testing.
2005-06-19 05:53:15 +00:00
Raymond Hettinger
15056a5202 SF 1062353: set pickling problems
Support automatic pickling of dictionaries in instance of set subclasses.
2004-11-09 07:25:31 +00:00
Raymond Hettinger
6429a4727e Use Py_CLEAR(). Add unrelated test. 2004-09-28 01:51:35 +00:00
Nicholas Bastin
9ba301e589 Moved SunPro warning suppression into pyport.h and out of individual
modules and objects.
2004-07-15 15:54:05 +00:00
Nicholas Bastin
1ce9e4cfc1 Fixed end-of-loop code not reached warning when using SunPro C 2004-06-17 18:27:18 +00:00
Raymond Hettinger
148a63f1fc Remove a function no longer in use. 2004-06-14 04:24:41 +00:00
Raymond Hettinger
47edb4b09c Remove unnecessary GC support. Sets cannot have cycles. 2004-06-13 08:20:46 +00:00
Raymond Hettinger
c978633ec6 Futher improvements to frozenset hashing (based on Yitz Gale's battery of
tests which nicely highly highlight weaknesses).

* Initial value is now a large prime.
* Pre-multiply by the set length to add one more basis of differentiation.
* Work a bit harder inside the loop to scatter bits from sources that
  may have closely spaced hash values.

All of this is necessary to make up for keep the hash function commutative.
Fortunately, the hash value is cached so the call to frozenset_hash() will
only occur once per set.
2004-06-10 22:41:48 +00:00
Raymond Hettinger
27e403ebe9 Fixups to the hash function for frozensets.
* Non-zero initial value so that hash(frozenset()) != hash(0).
* Final permutation to differentiate nested sets.
* Add logic to make sure that -1 is not a possible hash value.
2004-06-10 21:38:41 +00:00
Raymond Hettinger
691d80532b Make sets and deques weak referencable. 2004-05-30 07:26:47 +00:00
Raymond Hettinger
3fd500b4a5 The copy module now handles sets directly. The __copy__ methods are no
longer needed.
2004-03-08 18:31:10 +00:00
Raymond Hettinger
a3b11e7fb3 * Simplify and speedup logic for tp_print.
* Speed-up intersection whenever PyDict_Next can be used.
2003-12-31 14:08:58 +00:00
Raymond Hettinger
81ad32e435 Speedup set.update by using the override mode for PyDict_Merge(). 2003-12-15 21:16:06 +00:00
Raymond Hettinger
fb4e33a8e2 Improve algorithm for set.difference when the input is not a set. 2003-12-15 13:23:55 +00:00
Raymond Hettinger
438e02dfc8 * Refactor set.__contains__()
* Use Py_RETURN_NONE everywhere.
* Fix-up the firstpass check for the tp_print slot.
2003-12-13 19:38:47 +00:00
Raymond Hettinger
0deab62704 Refactor set.discard() and set.remove(). 2003-12-13 18:53:18 +00:00
Raymond Hettinger
dc5ae11abf Use dictionary specific looping idiom where possible.
Simplifies and speeds-up the code.
2003-12-13 14:46:46 +00:00
Raymond Hettinger
8f5cdaa784 * Added a new method flag, METH_COEXIST.
* Used the flag to optimize set.__contains__(), dict.__contains__(),
  dict.__getitem__(), and list.__getitem__().
2003-12-13 11:26:12 +00:00
Raymond Hettinger
bc0f2ab9bb Expose dict_contains() and PyDict_Contains() with is about 10% faster
than PySequence_Contains() and more clearly applicable to dicts.

Apply the new function in setobject.c where __contains__ checking is
ubiquitous.
2003-11-25 21:12:14 +00:00
Raymond Hettinger
a38123e2fa Factor out more duplicate code. 2003-11-24 22:18:49 +00:00
Guido van Rossum
5f4e45d66f Stop GCC warning about int literal that's so long that it becomes an
unsigned int (on a 32-bit machine), by adding an explicit 'u' to the
literal (a prime used to improve the hash function for frozenset).
2003-11-24 04:13:13 +00:00
Raymond Hettinger
f5f41bf087 * Checkin remaining documentation
* Add more tests
* Refactor and neaten the code a bit.
* Rename union_update() to update().
* Improve the algorithms (making them a closer to sets.py).
2003-11-24 02:57:33 +00:00