summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Clear dummy and emptyfrozenset, so that we don't haveMartin v. Löwis2006-04-151-2/+2
| | | | | dangling references in case of a Py_Initialize/Py_Finalize cycle.
* Ignore the references to the dummy objects used as deleted keysArmin Rigo2006-04-121-0/+8
| | | | in dicts and sets when computing the total number of references.
* Remove "static forward" declaration. Move constructorsMartin v. Löwis2006-04-111-17/+15
| | | | after the type objects.
* SF patch #1458476 with modifications based on discussions in python-dev. ThisBarry Warsaw2006-03-301-1/+68
| | | | | | adds the following API calls: PySet_Clear(), _PySet_Next(), and _PySet_Update(). The latter two are considered non-public. Tests and documentation (for the public API) are included.
* Remove unnecessary casts in type object initializers.Georg Brandl2006-03-301-4/+4
|
* Tighten an overbroad and misleading assertion.Raymond Hettinger2006-03-261-1/+1
| | | | (Reported by Jim Jewett.)
* Use Py_ssize_t for PySet_Size() like all the other Py*_Size() functions.Neal Norwitz2006-03-041-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-18/+19
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-2/+2
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Remove some shadowed variablesNeal Norwitz2006-01-081-1/+1
|
* Prevent name pollution by making lots of internal functions static.Neal Norwitz2005-11-131-1/+1
|
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-7/+12
|
* No longer ignore exceptions raised by comparisons during key lookup.Raymond Hettinger2005-09-161-48/+44
| | | | Inspired by Armin Rigo's suggestion to do the same with dictionaries.
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-261-0/+6
| | | | (fixes bug #1119418)
* * Add a fast equality check path for frozensets where the hash value hasRaymond Hettinger2005-08-241-5/+8
| | | | | already been computed. * Apply a GET_SIZE macro().
* Add shortcuts for a|a and a&a.Raymond Hettinger2005-08-171-8/+9
|
* Results of a line-by-line comparison back to dictobject.c.Raymond Hettinger2005-08-171-127/+121
| | | | | | | | | | | | * set_merge() cannot assume that the table doesn't resize during iteration. * convert some unnecessary tests to asserts -- they were necessary in dictobject.c because PyDict_Next() is a public function. The same is not true for set_next(). * re-arrange the order of functions to more closely match the order in dictobject.c. This makes it must easier to compare the two and ought to simplify any issues of maintaining both.
* Numerous fix-ups to C API and docs. Added tests for C API.Raymond Hettinger2005-08-161-9/+120
|
* DECREF --> XDECREFRaymond Hettinger2005-08-161-1/+1
|
* Add a C API for sets and frozensets.Raymond Hettinger2005-08-161-8/+72
|
* More function re-ordering (placing like functions together).Raymond Hettinger2005-08-131-86/+86
|
* * Bring lookkey() and lookkey_string() closer to dict version.Raymond Hettinger2005-08-131-93/+77
| | | | | * Use set_next() for looping in issubset() and frozenset_hash(). * Re-order the presentation of cmp and hash functions.
* * Fix SF #1257731. Make __contains__(), remove(), and discard() only doRaymond Hettinger2005-08-121-26/+30
| | | | | | | a frozenset conversion when the initial search attempt fails with a TypeError and the key is some type of set. Add a testcase. * Eliminate a duplicate if-stmt.
* * Add short-circuit code for in-place operations with self (such asRaymond Hettinger2005-08-111-89/+153
| | | | | | | | | | | | | | | | | | | | | s|=s, s&=s, s-=s, or s^=s). Add related tests. * Improve names for several variables and functions. * Provide alternate table access functions (next, contains, add, and discard) that work with an entry argument instead of just a key. This improves set-vs-set operations because we already have a hash value for each key and can avoid unnecessary calls to PyObject_Hash(). Provides a 5% to 20% speed-up for quick hashing elements like strings and integers. Provides much more substantial improvements for slow hashing elements like tuples or objects defining a custom __hash__() function. * Have difference operations resize() when 1/5 of the elements are dummies. Formerly, it was 1/6. The new ratio triggers less frequently and only in cases that it can resize quicker and with greater benefit. The right answer is probably either 1/4, 1/5, or 1/6. Picked the middle value for an even trade-off between resize time and the space/time costs of dummy entries.
* * Bring in INIT_NONZERO_SET_SLOTS macro from dictionary code.Raymond Hettinger2005-08-071-18/+51
| | | | | | | | * Bring in free list from dictionary code. * Improve several comments. * Differencing can leave many dummy entries. If more than 1/6 are dummies, then resize them away. * Factor-out common code with new macro, PyAnySet_CheckExact.
* * Removed checked_error flag which no longer provides any benefit.Raymond Hettinger2005-08-061-15/+12
| | | | * Have issubset() control its own loop instead of using set_next_internal().
* * set_new() doesn't need to zero the structure a second time after tp_allocRaymond Hettinger2005-08-061-3/+6
| | | | | has already done the job. * Use a macro form of PyErr_Occurred() inside the set_lookkey() function.
* Factor away a redundant clear() function.Raymond Hettinger2005-08-061-13/+6
|
* * Improve a variable name: entry0 --> table.Raymond Hettinger2005-08-051-39/+58
| | | | | | | | | | * Give set_lookkey_string() a fast alternate path when no dummy entries are present. * Have set_swap_bodies() reset the hash field to -1 whenever either of bodies is not a frozenset. Maintains the invariant of regular sets always having -1 in the hash field; otherwise, any mutation would make the hash value invalid. * Use an entry pointer to simplify the code in frozenset_hash().
* * Move copyright notice to top and indicate derivation from sets.py andRaymond Hettinger2005-08-051-22/+17
| | | | | | | dictobject.c. * Have frozenset_hash() use entry->hash instead of re-computing each individual hash with PyObject_Hash(o); * Finalize the dummy entry before a system exit.
* Model set.pop() after dict.popitem().Raymond Hettinger2005-08-021-12/+30
|
* * Improve code for the empty frozenset singleton:Raymond Hettinger2005-08-011-63/+66
| | | | | | | | | | | - Handle both frozenset() and frozenset([]). - Do not use singleton for frozenset subclasses. - Finalize the singleton. - Add test cases. * Factor-out set_update_internal() from set_update(). Simplifies the code for several internal callers. * Factor constant expressions out of loop in set_merge_internal(). * Minor comment touch-ups.
* Fix build on gcc: PySetIter_Type should be static in definitionHye-Shik Chang2005-08-011-1/+1
| | | | part also.
* Improve variable names.Raymond Hettinger2005-07-311-154/+154
|
* Fix frozenset() ref count and a comment typo.Raymond Hettinger2005-07-311-3/+2
|
* Comment on the set_swap_bodies() helper function.Raymond Hettinger2005-07-311-0/+13
|
* Revised the set() and frozenset() implementaion to use its own internalRaymond Hettinger2005-07-311-211/+863
| | | | | data structure instead of using dictionaries. Reduces memory consumption by 1/3 and provides modest speed-ups for most set operations.
* SF patch #1200018: Restore GC support to set objectsRaymond Hettinger2005-06-181-7/+24
| | | | | Reverts 1.26 and 1.27. And adds cycle testing.
* SF 1062353: set pickling problemsRaymond Hettinger2004-11-091-2/+9
| | | | Support automatic pickling of dictionaries in instance of set subclasses.
* Use Py_CLEAR(). Add unrelated test.Raymond Hettinger2004-09-281-1/+1
|
* Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin2004-07-151-4/+0
| | | | modules and objects.
* Fixed end-of-loop code not reached warning when using SunPro CNicholas Bastin2004-06-171-0/+4
|
* Remove a function no longer in use.Raymond Hettinger2004-06-141-8/+0
|
* Remove unnecessary GC support. Sets cannot have cycles.Raymond Hettinger2004-06-131-16/+7
|
* Futher improvements to frozenset hashing (based on Yitz Gale's battery ofRaymond Hettinger2004-06-101-8/+10
| | | | | | | | | | | | | 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.
* Fixups to the hash function for frozensets.Raymond Hettinger2004-06-101-1/+4
| | | | | | * 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.
* Make sets and deques weak referencable.Raymond Hettinger2004-05-301-4/+8
|
* The copy module now handles sets directly. The __copy__ methods are noRaymond Hettinger2004-03-081-4/+0
| | | | longer needed.
* * Simplify and speedup logic for tp_print.Raymond Hettinger2003-12-311-15/+29
| | | | * Speed-up intersection whenever PyDict_Next can be used.
* Speedup set.update by using the override mode for PyDict_Merge().Raymond Hettinger2003-12-151-1/+1
|