42 Commits

Author SHA1 Message Date
Andrew M. Kuchling
c45e5d9d91 [Backport r50782 | neal.norwitz]
nextlink can be NULL if teedataobject_new fails, so use XINCREF.
Ensure that dataobj is never NULL.

Reported by Klocwork #102
2006-10-03 19:22:30 +00:00
Andrew M. Kuchling
e7031223e3 [Backport of rev. 42093 by neal.norwitz]
Check return result from Py_InitModule*().  This API can fail.

Probably should be backported.
2006-09-27 19:17:32 +00:00
Georg Brandl
66e75ac6e0 Disallow keyword arguments for type constructors that don't use them
(fixes #1119418).
2005-08-26 06:43:16 +00:00
Fred Drake
08ebfec75e some platforms still need offsetof() from structmember.h 2004-10-17 19:36:57 +00:00
Raymond Hettinger
a9f6092904 Fix and test weak referencing of itertools.tee objects. 2004-10-17 16:40:14 +00:00
Raymond Hettinger
880430e2a5 Replace structure member before decreffing. 2004-10-02 10:56:43 +00:00
Raymond Hettinger
4cda01e260 * Increase test coverage.
* Have groupby() be careful about decreffing structure members.
2004-09-28 04:45:28 +00:00
Raymond Hettinger
75ccea3777 SF patch #1020188: Use Py_CLEAR where necessary to avoid crashes
(Contributed by Dima Dorfman)
2004-09-01 07:02:44 +00:00
Raymond Hettinger
58ed69b402 Exercise Jim's VISIT macro. 2004-07-15 05:32:47 +00:00
Raymond Hettinger
9d7c870c6d SF #950057: itertools.chain doesn't "process" exceptions as they occur
Both cycle() and chain() were handling exceptions only when switching
input sources.  The patch makes the handle more immediate.

Will backport.
2004-05-08 19:49:42 +00:00
Brett Cannon
0046839dd2 Change two instance of format strings for PyString_FromFormat() to use %ld
instead of %d .
2004-04-13 02:43:53 +00:00
Raymond Hettinger
7dacda2947 Provide more information representations of repeat() and count(). 2004-04-08 21:54:00 +00:00
Raymond Hettinger
0faa1ca51d Speedup the inner loops for dropwhile(), islice(), ifilter(), and
ifilterfalse().
2004-03-17 04:27:44 +00:00
Skip Montanaro
f3938fd029 need to initialize ob_type slot at run-time, at least on cygwin 2004-02-10 20:27:40 +00:00
Raymond Hettinger
5cab2e3a88 Give itertools.repeat() a length method. 2004-02-10 09:25:40 +00:00
Raymond Hettinger
d25c1c6351 Implement itertools.groupby()
Original idea by Guido van Rossum.
Idea for skipable inner iterators by Raymond Hettinger.
Idea for argument order and identity function default by Alex Martelli.
Implementation by Hye-Shik Chang (with tweaks by Raymond Hettinger).
2003-12-06 16:23:06 +00:00
Raymond Hettinger
ad983e79d6 Improve the implementation of itertools.tee().
Formerly, underlying queue was implemented in terms of two lists.  The
new queue is a series of singly-linked fixed length lists.

The new implementation runs much faster, supports multi-way tees, and
allows tees of tees without additional memory costs.

The root ideas for this structure were contributed by Andrew Koenig
and Guido van Rossum.
2003-11-12 14:32:26 +00:00
Raymond Hettinger
0e4f76405d Fix nits in error messages. 2003-10-28 07:32:28 +00:00
Raymond Hettinger
f0c5aec85f Minor improvements to itertools.tee():
* tee object is no longer subclassable
* independent iterators renamed to "itertools.tee_iterator"
* fixed doc string typo and added entry in the module doc string
2003-10-26 14:25:56 +00:00
Raymond Hettinger
4514369f27 Improvements to coding for itertools.tee():
* Add error checking code to PyList_Append() call.

* Replace PyObject_CallMethod(to->outbasket, "pop", NULL) with equivalent
  in-line code.  Inlining is important here because the search for the
  pop method will occur for every element returned by the iterator.

* Make tee's dealloc() a little smarter.  If the trailing iterator is
  being deallocated, then the queue data is no longer needed and can
  be freed.
2003-10-25 06:37:47 +00:00
Raymond Hettinger
6a5b027742 Added itertools.tee()
It works like the pure python verion except:
* it stops storing data after of the iterators gets deallocated
* the data queue is implemented with two stacks instead of one dictionary.
2003-10-24 08:45:23 +00:00
Raymond Hettinger
4f01f89b8c For safety, replace a tuple entry before decreffing it. 2003-08-30 00:10:06 +00:00
Raymond Hettinger
a56f6b6600 SF bug #793826: using itertools.izip to mutate tuples
Avoid Armin Rigo's dastardly exercise in re-entrancy.
2003-08-29 23:09:58 +00:00
Raymond Hettinger
b5a420883c Modified itertools.izip() to match the behavior of __builtin__.zip()
which can now take zero arguments.
2003-08-08 05:10:41 +00:00
Raymond Hettinger
1d7a3489e9 SF patch #770521: make itertools type declarations static
(Contributed by Andrew I MacIntyre.)
2003-07-14 07:07:12 +00:00