summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_tJack Diederich2006-09-211-1/+1
| | | | | | which breaks negative counts * added test for negative numbers will backport to 2.5.1
* Bug #1550714: fix SystemError from itertools.tee on negative value for n.Neal Norwitz2006-09-021-2/+6
| | | | Needs backport to 2.5.1 and earlier.
* nextlink can be NULL if teedataobject_new fails, so use XINCREF.Neal Norwitz2006-07-231-2/+8
| | | | | | Ensure that dataobj is never NULL. Reported by Klocwork #102
* Fix compiler warning (and whitespace) on Mac OS 10.4. (A lot of this code ↵Neal Norwitz2006-05-271-4/+4
| | | | looked duplicated, I wonder if a utility function could help reduce the duplication here.)
* use Py_ssize_t in places that may need itJack Diederich2006-05-261-25/+25
|
* Add missing PyObject_GC_Track call, causing *some* itertools.tee objects toThomas Wouters2006-04-151-0/+1
| | | | | | | | | not be tracked by GC. This fixes 254 of test_generators' refleaks on my machine, but I'm sure something else will make them come back :> Not adding a separate test for this kind of cycle, since the existing fib/m235 already test them in more extensive ways than any 'minimal' test has been able to manage.
* Make itertools.tee and its internal teedataobject participate in GC. ThisThomas Wouters2006-03-271-19/+71
| | | | | alone does not solve the leak in test_generators, unfortunately, but it is part of test_generators' problem and it does solve other cycles.
* More unconsting.Martin v. Löwis2006-02-271-1/+1
|
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-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.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-1/+1
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-8/+12
|
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-261-0/+36
| | | | (fixes bug #1119418)
* Added optional None arguments to itertools.islice().Raymond Hettinger2004-12-051-14/+16
|
* some platforms still need offsetof() from structmember.hFred Drake2004-10-171-0/+1
|
* Fix and test weak referencing of itertools.tee objects.Raymond Hettinger2004-10-171-1/+6
|
* Replace structure member before decreffing.Raymond Hettinger2004-10-021-1/+3
|
* * Increase test coverage.Raymond Hettinger2004-09-281-5/+9
| | | | * Have groupby() be careful about decreffing structure members.
* SF patch #1020188: Use Py_CLEAR where necessary to avoid crashesRaymond Hettinger2004-09-011-2/+1
| | | | (Contributed by Dima Dorfman)
* Exercise Jim's VISIT macro.Raymond Hettinger2004-07-151-129/+24
|
* SF #950057: itertools.chain doesn't "process" exceptions as they occurRaymond Hettinger2004-05-081-0/+12
| | | | | | | Both cycle() and chain() were handling exceptions only when switching input sources. The patch makes the handle more immediate. Will backport.
* Change two instance of format strings for PyString_FromFormat() to use %ldBrett Cannon2004-04-131-2/+2
| | | | instead of %d .
* Provide more information representations of repeat() and count().Raymond Hettinger2004-04-081-2/+27
|
* Speedup the inner loops for dropwhile(), islice(), ifilter(), andRaymond Hettinger2004-03-171-9/+17
| | | | ifilterfalse().
* need to initialize ob_type slot at run-time, at least on cygwinSkip Montanaro2004-02-101-1/+2
|
* Give itertools.repeat() a length method.Raymond Hettinger2004-02-101-1/+14
|
* Implement itertools.groupby()Raymond Hettinger2003-12-061-1/+321
| | | | | | | 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).
* Improve the implementation of itertools.tee().Raymond Hettinger2003-11-121-181/+199
| | | | | | | | | | | 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.
* Fix nits in error messages.Raymond Hettinger2003-10-281-4/+4
|
* Minor improvements to itertools.tee():Raymond Hettinger2003-10-261-9/+9
| | | | | | * 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
* Improvements to coding for itertools.tee():Raymond Hettinger2003-10-251-3/+26
| | | | | | | | | | | | * 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.
* Added itertools.tee()Raymond Hettinger2003-10-241-0/+259
| | | | | | 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.
* For safety, replace a tuple entry before decreffing it.Raymond Hettinger2003-08-301-1/+3
|
* SF bug #793826: using itertools.izip to mutate tuplesRaymond Hettinger2003-08-291-2/+4
| | | | Avoid Armin Rigo's dastardly exercise in re-entrancy.
* Modified itertools.izip() to match the behavior of __builtin__.zip()Raymond Hettinger2003-08-081-6/+2
| | | | which can now take zero arguments.
* SF patch #770521: make itertools type declarations staticRaymond Hettinger2003-07-141-24/+24
| | | | (Contributed by Andrew I MacIntyre.)
* Minor updates:Raymond Hettinger2003-06-181-3/+13
| | | | | | * Updated comment on design of imap() * Added untraversed object in izip() structure * Replaced the pairwise() example with a more general window() example
* Add missing DECREF.Raymond Hettinger2003-06-171-1/+3
|
* PyType_GenericAlloc is inherited from object.Raymond Hettinger2003-05-231-12/+12
|
* Fixed dotted name assertion.Raymond Hettinger2003-05-221-2/+2
|
* * Added a substantial number of edge case and argument tests forRaymond Hettinger2003-05-031-0/+3
| | | | | | | the itertoolsmodule. * Taught itertools.repeat(obj, n) to treat negative repeat counts as zero. This behavior matches that for sequences and prevents infinite loops.
* The previous made the stop argument optional.Raymond Hettinger2003-05-021-2/+2
| | | | It is better to be explicit and just allow stop to be None.
* SF bug #730685: itertools.islice stop argument is not optionalRaymond Hettinger2003-05-021-13/+33
| | | | | * itertools.islice() stop argument did not perform as documented. * beefed-up test suite
* Fix docstring typoAndrew M. Kuchling2003-04-141-1/+1
|
* Renamed PyObject_GenericGetIter to PyObject_SelfIterRaymond Hettinger2003-03-171-12/+12
| | | | | | to more accurately describe what the function does. Suggested by Thomas Wouters.
* Created PyObject_GenericGetIter().Raymond Hettinger2003-03-171-96/+12
| | | | Factors out the common case of returning self.
* Several of the tools can make direct calls the inner iterators.Raymond Hettinger2003-03-011-9/+24
|
* User requested changes to the itertools module.Raymond Hettinger2003-02-231-52/+236
| | | | | Subsumed times() into repeat(). Added cycle() and chain().
* Remove unused variable.Guido van Rossum2003-02-091-1/+1
|