summaryrefslogtreecommitdiffstats
path: root/Modules/collectionsmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* - Patch 1433928:Guido van Rossum2006-02-251-1/+265
| | | | | | | | - The copy module now "copies" function objects (as atomic objects). - dict.__getitem__ now looks for a __missing__ hook before raising KeyError. - Added a new type, defaultdict, to the collections module. This uses the new __missing__ hook behavior added to dict (see above).
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-8/+8
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-2/+2
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Check return result from Py_InitModule*(). This API can fail.Neal Norwitz2006-01-191-0/+2
| | | | Probably should be backported.
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-7/+11
|
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-261-0/+3
| | | | (fixes bug #1119418)
* Apply remove's mutation test after every equality test.Raymond Hettinger2005-03-191-7/+7
|
* Add a remove() method to collections.deque objects.Raymond Hettinger2005-03-181-1/+38
|
* SF patch #1062279: deque pickling problemsRaymond Hettinger2004-11-091-10/+12
| | | | | | | (Contributed by Dima Dorfman.) * Support pickling of dictionaries in instances of deque subclasses. * Support pickling of recursive deques.
* Bump-up block size.Raymond Hettinger2004-11-021-1/+1
|
* Simplify delitem() code by calling rotate() directly instead of usingRaymond Hettinger2004-10-091-35/+23
| | | | arguments passed through tuples.
* Armin's patch to prevent overflows.Raymond Hettinger2004-10-061-7/+22
|
* Upon insertion, if memory runs out, the deque was left in a corrupted state.Armin Rigo2004-10-021-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | deque_item(): a performance bug: the linked list of blocks was followed from the left in most cases, because the test (i < (deque->len >> 1)) was after "i %= BLOCKLEN". deque_clear(): replaced a call to deque_len() with deque->len; not sure what this call was here for, nor if all compilers under the sun would inline it. deque_traverse(): I belive that it could be called by the GC when the deque has leftblock==rightblock==NULL, because it is tracked before the first block is allocated (though closely before). Still, a C extension module subclassing deque could provide its own tp_alloc that could trigger a GC collection after the PyObject_GC_Track()... deque_richcompare(): rewrote to cleanly check for end-of-iterations instead of relying on deque.__iter__().next() to succeed exactly len(deque) times -- an assumption which can break if deques are subclassed. Added a test. I wonder if the length should be explicitely bounded to INT_MAX, with OverflowErrors, as in listobject.c. On 64-bit machines, adding more than INT_MAX in the deque will result in trouble. (Note to anyone/me fixing this: carefully check for overflows if len is close to INT_MAX in the following functions: deque_rotate(), deque_item(), deque_ass_item())
* * Bulletproof the method for detecting mutations during iteration.Raymond Hettinger2004-10-021-18/+32
| | | | | | | | | The previous approach was too easily fooled (a rotate() sufficed). * Use it->counter to determine when iteration is complete. The previous approach was too complex. * Strengthen an assertion and add a comment here or there.
* Restore the block length and add a comment.Raymond Hettinger2004-10-011-1/+7
|
* Clarify the relationship between indices.Raymond Hettinger2004-10-011-5/+7
|
* * Elaborate on the invariant comments and make them more precise.Raymond Hettinger2004-10-011-14/+28
| | | | | | * Change the centering by one to make it possible to test the module with BLOCKLEN's as low as two. Testing small blocks makes end-point errors surface more readily.
* deque_traverse(): If the deque had one block, and its rightindex wasTim Peters2004-10-011-10/+13
| | | | | BLOCKLEN-1, this assert-failed in a debug build, or went wild with a NULL pointer in a release build. Reported on c.l.py by Stefan Behnel.
* Typos in new comments.Tim Peters2004-10-011-2/+2
|
* Document some reverse-engineered invariants and pragmatic hints.Tim Peters2004-10-011-2/+17
|
* Definition consistency.Tim Peters2004-10-011-1/+2
|
* Trimmed trailing whitespace.Tim Peters2004-10-011-26/+26
|
* Silence a GCC unused variable warning in debug builds.Raymond Hettinger2004-07-191-2/+1
|
* Apply VISIT macro.Raymond Hettinger2004-07-151-5/+3
|
* Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin2004-07-151-4/+0
| | | | modules and objects.
* * balance the left/right search for getitem.Raymond Hettinger2004-07-091-15/+13
| | | | | * use assertions instead of tests after internal calls that can't fail. * expand test coverage
* Add a comment with implementation notes.Raymond Hettinger2004-06-261-0/+7
|
* Fixed end-of-loop code not reached warning when using SunPro CNicholas Bastin2004-06-171-0/+4
|
* Make sets and deques weak referencable.Raymond Hettinger2004-05-301-2/+8
|
* Make type check work with subclassesRaymond Hettinger2004-05-181-1/+2
|
* Make sure "del d[n]" is properly supported. Was necessary because theRaymond Hettinger2004-05-121-0/+41
| | | | | | same method that implements __setitem__ also implements __delitem__. Also, there were several good use cases (removing items from a queue and implementing Forth style stack ops).
* * Add unittests for iterators that report their lengthRaymond Hettinger2004-04-121-0/+2
| | | | | | * Document the differences between them * Fix corner cases covered by the unittests * Use Py_RETURN_NONE where possible for dictionaries
* Improve deque iteration.Raymond Hettinger2004-03-181-1/+102
| | | | | | * The default __reversed__ performed badly, so reintroduced a custom reverse iterator. * Added length transparency to improve speed with map(), list(), etc.
* Special case endpoint access for speed.Raymond Hettinger2004-03-041-10/+18
|
* Replace left(), right(), and __reversed__() with the more general purposeRaymond Hettinger2004-03-011-123/+69
| | | | | | | __getitem__() and __setitem__(). Simplifies the API, reduces the code size, adds flexibility, and makes deques work with bisect.bisect(), random.shuffle(), and random.sample().
* Make deque_type static so namespace is not polluted.Neal Norwitz2004-02-291-2/+2
|
* Improvements to collections.deque():Raymond Hettinger2004-02-291-3/+117
| | | | | | | | * Add doctests for the examples in the library reference. * Add two methods, left() and right(), modeled after deques in C++ STL. * Apply the new method to asynchat.py. * Add comparison operators to make deques more substitutable for lists. * Replace the LookupErrors with IndexErrors to more closely match lists.
* Get rid of unused variableNeal Norwitz2004-02-281-1/+0
|
* Make deque.rotate() smarter. Beef-up related tests.Raymond Hettinger2004-02-081-4/+11
|
* * Incorporate Skip's suggestions for documentation (explain the word dequeRaymond Hettinger2004-02-071-4/+44
| | | | | comes from and show the differences from lists). * Add a rotate() method.
* * Fix ref counting in extend() and extendleft().Raymond Hettinger2004-02-071-4/+93
| | | | * Let deques support reversed().
* Have deques support high volume loads.Raymond Hettinger2004-02-061-23/+74
|
* Fix spelling.Raymond Hettinger2004-01-291-2/+2
|
* * Move collections.deque() in from the sandboxRaymond Hettinger2004-01-291-0/+582
* Add unittests, newsitem, and whatsnew * Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py * Docs are forthcoming