Commit Graph

28 Commits

Author SHA1 Message Date
Christian Heimes c5f05e45cf Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
Raymond Hettinger adf9ffdfbe Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate. 2007-12-13 00:08:37 +00:00
Raymond Hettinger 68995867d5 Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques. 2007-10-10 00:26:46 +00:00
Raymond Hettinger a7fc4b13e0 Add __asdict__() to NamedTuple and refine the docs.
Add maxlen support to deque() and fixup docs.
Partially fix __reduce__().  The None as a third arg was no longer supported.
Still needs work on __reduce__() to handle recursive inputs.
2007-10-05 02:47:07 +00:00
Georg Brandl b84c13792d Bug #1486663: don't reject keyword arguments for subclasses of builtin
types.
2007-01-21 10:28:43 +00:00
Raymond Hettinger 51c2f6cd18 Fix zero-length corner case for iterating over a mutating deque. 2007-01-08 18:09:20 +00:00
Walter Dörwald 09a3f2cc2f Add tests for tuple, list and UserList that initialize the object from
various iterables.

(Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274)
2005-03-22 22:43:28 +00:00
Walter Dörwald c448a91ee8 Fix typo. 2005-03-22 11:22:38 +00:00
Raymond Hettinger d73202c596 Apply remove's mutation test after every equality test. 2005-03-19 00:00:51 +00:00
Raymond Hettinger 4aec61e0fc Add a remove() method to collections.deque objects. 2005-03-18 21:20:23 +00:00
Raymond Hettinger 952f8808b2 SF patch #1062279: deque pickling problems
(Contributed by Dima Dorfman.)

* Support pickling of dictionaries in instances of deque subclasses.
* Support pickling of recursive deques.
2004-11-09 07:27:35 +00:00
Armin Rigo 974d757af1 Upon insertion, if memory runs out, the deque was left in a corrupted state.
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())
2004-10-02 13:59:34 +00:00
Tim Peters 10c7e86454 deque_traverse(): If the deque had one block, and its rightindex was
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.
2004-10-01 02:01:04 +00:00
Raymond Hettinger ffdb8bb99c Use floor division operator. 2004-09-27 15:29:05 +00:00
Raymond Hettinger 770acc2bb4 Remove unnecessary line. 2004-08-26 04:29:47 +00:00
Raymond Hettinger a435c53e13 * balance the left/right search for getitem.
* use assertions instead of tests after internal calls that can't fail.
* expand test coverage
2004-07-09 04:10:20 +00:00
Raymond Hettinger 691d80532b Make sets and deques weak referencable. 2004-05-30 07:26:47 +00:00
Raymond Hettinger 354433a59d SF patch #872326: Generator expression implementation
(Code contributed by Jiwon Seo.)

The documentation portion of the patch is being re-worked and will be
checked-in soon.  Likewise, PEP 289 will be updated to reflect Guido's
rationale for the design decisions on binding behavior (as described in
in his patch comments and in discussions on python-dev).

The test file, test_genexps.py, is written in doctest format and is
meant to exercise all aspects of the the patch.  Further additions are
welcome from everyone.  Please stress test this new feature as much as
possible before the alpha release.
2004-05-19 08:20:33 +00:00
Raymond Hettinger 0e371f2cb6 Make sure "del d[n]" is properly supported. Was necessary because the
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).
2004-05-12 20:55:56 +00:00
Raymond Hettinger 300fa1d3b2 Temporarily disable doctest until genexps are in CVS 2004-05-10 14:08:42 +00:00
Raymond Hettinger e7169eb9ed Add more examples. 2004-05-09 01:15:01 +00:00
Raymond Hettinger 0a4977c2f3 Replace left(), right(), and __reversed__() with the more general purpose
__getitem__() and __setitem__().

Simplifies the API, reduces the code size, adds flexibility, and makes
deques work with bisect.bisect(), random.shuffle(), and random.sample().
2004-03-01 23:16:22 +00:00
Raymond Hettinger 738ec90ca1 Improvements to collections.deque():
* 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.
2004-02-29 02:15:56 +00:00
Raymond Hettinger ee33b27ef0 Make deque.rotate() smarter. Beef-up related tests. 2004-02-08 04:05:26 +00:00
Raymond Hettinger 5c5eb86347 * Incorporate Skip's suggestions for documentation (explain the word deque
comes from and show the differences from lists).
* Add a rotate() method.
2004-02-07 21:13:00 +00:00
Raymond Hettinger c058fd14a9 * Fix ref counting in extend() and extendleft().
* Let deques support reversed().
2004-02-07 02:45:22 +00:00
Raymond Hettinger 3ba85c2e8a Have deques support high volume loads. 2004-02-06 19:04:56 +00:00
Raymond Hettinger 756b3f3c15 * Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
2004-01-29 06:37:52 +00:00