Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c4bccd3c
Commit
c4bccd3c
authored
Sep 12, 2018
by
Tal Einat
Committed by
Raymond Hettinger
Sep 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-20180: convert most of itertoolsmodule.c to use Argument Clinic (GH-9164)
parent
90fc8980
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
694 additions
and
219 deletions
+694
-219
Modules/clinic/itertoolsmodule.c.h
Modules/clinic/itertoolsmodule.c.h
+449
-1
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+245
-218
No files found.
Modules/clinic/itertoolsmodule.c.h
View file @
c4bccd3c
...
@@ -61,4 +61,452 @@ itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs)
...
@@ -61,4 +61,452 @@ itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit:
exit:
return
return_value
;
return
return_value
;
}
}
/*[clinic end generated code: output=82e10c91569d2b95 input=a9049054013a1b77]*/
PyDoc_STRVAR
(
itertools_teedataobject__doc__
,
"teedataobject(iterable, values, next, /)
\n
"
"--
\n
"
"
\n
"
"Data container common to multiple tee objects."
);
static
PyObject
*
itertools_teedataobject_impl
(
PyTypeObject
*
type
,
PyObject
*
it
,
PyObject
*
values
,
PyObject
*
next
);
static
PyObject
*
itertools_teedataobject
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
it
;
PyObject
*
values
;
PyObject
*
next
;
if
((
type
==
&
teedataobject_type
)
&&
!
_PyArg_NoKeywords
(
"teedataobject"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_ParseTuple
(
args
,
"OO!O:teedataobject"
,
&
it
,
&
PyList_Type
,
&
values
,
&
next
))
{
goto
exit
;
}
return_value
=
itertools_teedataobject_impl
(
type
,
it
,
values
,
next
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools__tee__doc__
,
"_tee(iterable, /)
\n
"
"--
\n
"
"
\n
"
"Iterator wrapped to make it copyable."
);
static
PyObject
*
itertools__tee_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
);
static
PyObject
*
itertools__tee
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
iterable
;
if
((
type
==
&
tee_type
)
&&
!
_PyArg_NoKeywords
(
"_tee"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"_tee"
,
1
,
1
,
&
iterable
))
{
goto
exit
;
}
return_value
=
itertools__tee_impl
(
type
,
iterable
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_tee__doc__
,
"tee($module, iterable, n=2, /)
\n
"
"--
\n
"
"
\n
"
"Returns a tuple of n independent iterators."
);
#define ITERTOOLS_TEE_METHODDEF \
{"tee", (PyCFunction)itertools_tee, METH_FASTCALL, itertools_tee__doc__},
static
PyObject
*
itertools_tee_impl
(
PyObject
*
module
,
PyObject
*
iterable
,
Py_ssize_t
n
);
static
PyObject
*
itertools_tee
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
iterable
;
Py_ssize_t
n
=
2
;
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
"O|n:tee"
,
&
iterable
,
&
n
))
{
goto
exit
;
}
return_value
=
itertools_tee_impl
(
module
,
iterable
,
n
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_cycle__doc__
,
"cycle(iterable, /)
\n
"
"--
\n
"
"
\n
"
"Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."
);
static
PyObject
*
itertools_cycle_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
);
static
PyObject
*
itertools_cycle
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
iterable
;
if
((
type
==
&
cycle_type
)
&&
!
_PyArg_NoKeywords
(
"cycle"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"cycle"
,
1
,
1
,
&
iterable
))
{
goto
exit
;
}
return_value
=
itertools_cycle_impl
(
type
,
iterable
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_dropwhile__doc__
,
"dropwhile(predicate, iterable, /)
\n
"
"--
\n
"
"
\n
"
"Drop items from the iterable while predicate(item) is true.
\n
"
"
\n
"
"Afterwards, return every element until the iterable is exhausted."
);
static
PyObject
*
itertools_dropwhile_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
);
static
PyObject
*
itertools_dropwhile
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
func
;
PyObject
*
seq
;
if
((
type
==
&
dropwhile_type
)
&&
!
_PyArg_NoKeywords
(
"dropwhile"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"dropwhile"
,
2
,
2
,
&
func
,
&
seq
))
{
goto
exit
;
}
return_value
=
itertools_dropwhile_impl
(
type
,
func
,
seq
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_takewhile__doc__
,
"takewhile(predicate, iterable, /)
\n
"
"--
\n
"
"
\n
"
"Return successive entries from an iterable as long as the predicate evaluates to true for each entry."
);
static
PyObject
*
itertools_takewhile_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
);
static
PyObject
*
itertools_takewhile
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
func
;
PyObject
*
seq
;
if
((
type
==
&
takewhile_type
)
&&
!
_PyArg_NoKeywords
(
"takewhile"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"takewhile"
,
2
,
2
,
&
func
,
&
seq
))
{
goto
exit
;
}
return_value
=
itertools_takewhile_impl
(
type
,
func
,
seq
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_starmap__doc__
,
"starmap(function, iterable, /)
\n
"
"--
\n
"
"
\n
"
"Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."
);
static
PyObject
*
itertools_starmap_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
);
static
PyObject
*
itertools_starmap
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
func
;
PyObject
*
seq
;
if
((
type
==
&
starmap_type
)
&&
!
_PyArg_NoKeywords
(
"starmap"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"starmap"
,
2
,
2
,
&
func
,
&
seq
))
{
goto
exit
;
}
return_value
=
itertools_starmap_impl
(
type
,
func
,
seq
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_chain_from_iterable__doc__
,
"from_iterable($type, iterable, /)
\n
"
"--
\n
"
"
\n
"
"Alternative chain() constructor taking a single iterable argument that evaluates lazily."
);
#define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \
{"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__},
PyDoc_STRVAR
(
itertools_combinations__doc__
,
"combinations(iterable, r)
\n
"
"--
\n
"
"
\n
"
"Return successive r-length combinations of elements in the iterable.
\n
"
"
\n
"
"combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"
);
static
PyObject
*
itertools_combinations_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
Py_ssize_t
r
);
static
PyObject
*
itertools_combinations
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"iterable"
,
"r"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"On:combinations"
,
_keywords
,
0
};
PyObject
*
iterable
;
Py_ssize_t
r
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
iterable
,
&
r
))
{
goto
exit
;
}
return_value
=
itertools_combinations_impl
(
type
,
iterable
,
r
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_combinations_with_replacement__doc__
,
"combinations_with_replacement(iterable, r)
\n
"
"--
\n
"
"
\n
"
"Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.
\n
"
"
\n
"
"combinations_with_replacement(
\'
ABC
\'
, 2) --> AA AB AC BB BC CC
\"
"
);
static
PyObject
*
itertools_combinations_with_replacement_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
Py_ssize_t
r
);
static
PyObject
*
itertools_combinations_with_replacement
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"iterable"
,
"r"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"On:combinations_with_replacement"
,
_keywords
,
0
};
PyObject
*
iterable
;
Py_ssize_t
r
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
iterable
,
&
r
))
{
goto
exit
;
}
return_value
=
itertools_combinations_with_replacement_impl
(
type
,
iterable
,
r
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_permutations__doc__
,
"permutations(iterable, r=None)
\n
"
"--
\n
"
"
\n
"
"Return successive r-length permutations of elements in the iterable.
\n
"
"
\n
"
"permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"
);
static
PyObject
*
itertools_permutations_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
PyObject
*
robj
);
static
PyObject
*
itertools_permutations
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"iterable"
,
"r"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"O|O:permutations"
,
_keywords
,
0
};
PyObject
*
iterable
;
PyObject
*
robj
=
Py_None
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
iterable
,
&
robj
))
{
goto
exit
;
}
return_value
=
itertools_permutations_impl
(
type
,
iterable
,
robj
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_accumulate__doc__
,
"accumulate(iterable, func=None)
\n
"
"--
\n
"
"
\n
"
"Return series of accumulated sums (or other binary function results)."
);
static
PyObject
*
itertools_accumulate_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
PyObject
*
binop
);
static
PyObject
*
itertools_accumulate
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"iterable"
,
"func"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"O|O:accumulate"
,
_keywords
,
0
};
PyObject
*
iterable
;
PyObject
*
binop
=
Py_None
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
iterable
,
&
binop
))
{
goto
exit
;
}
return_value
=
itertools_accumulate_impl
(
type
,
iterable
,
binop
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_compress__doc__
,
"compress(data, selectors)
\n
"
"--
\n
"
"
\n
"
"Return data elements corresponding to true selector elements.
\n
"
"
\n
"
"Forms a shorter iterator from selected data elements using the selectors to
\n
"
"choose the data elements."
);
static
PyObject
*
itertools_compress_impl
(
PyTypeObject
*
type
,
PyObject
*
seq1
,
PyObject
*
seq2
);
static
PyObject
*
itertools_compress
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"data"
,
"selectors"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"OO:compress"
,
_keywords
,
0
};
PyObject
*
seq1
;
PyObject
*
seq2
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
seq1
,
&
seq2
))
{
goto
exit
;
}
return_value
=
itertools_compress_impl
(
type
,
seq1
,
seq2
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_filterfalse__doc__
,
"filterfalse(function, iterable, /)
\n
"
"--
\n
"
"
\n
"
"Return those items of iterable for which function(item) is false.
\n
"
"
\n
"
"If function is None, return the items that are false."
);
static
PyObject
*
itertools_filterfalse_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
);
static
PyObject
*
itertools_filterfalse
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
func
;
PyObject
*
seq
;
if
((
type
==
&
filterfalse_type
)
&&
!
_PyArg_NoKeywords
(
"filterfalse"
,
kwargs
))
{
goto
exit
;
}
if
(
!
PyArg_UnpackTuple
(
args
,
"filterfalse"
,
2
,
2
,
&
func
,
&
seq
))
{
goto
exit
;
}
return_value
=
itertools_filterfalse_impl
(
type
,
func
,
seq
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
itertools_count__doc__
,
"count(start=0, step=1)
\n
"
"--
\n
"
"
\n
"
"Return a count object whose .__next__() method returns consecutive values.
\n
"
"
\n
"
"Equivalent to:
\n
"
" def count(firstval=0, step=1):
\n
"
" x = firstval
\n
"
" while 1:
\n
"
" yield x
\n
"
" x += step"
);
static
PyObject
*
itertools_count_impl
(
PyTypeObject
*
type
,
PyObject
*
long_cnt
,
PyObject
*
long_step
);
static
PyObject
*
itertools_count
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"start"
,
"step"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"|OO:count"
,
_keywords
,
0
};
PyObject
*
long_cnt
=
NULL
;
PyObject
*
long_step
=
NULL
;
if
(
!
_PyArg_ParseTupleAndKeywordsFast
(
args
,
kwargs
,
&
_parser
,
&
long_cnt
,
&
long_step
))
{
goto
exit
;
}
return_value
=
itertools_count_impl
(
type
,
long_cnt
,
long_step
);
exit:
return
return_value
;
}
/*[clinic end generated code: output=d9eb9601bd3296ef input=a9049054013a1b77]*/
Modules/itertoolsmodule.c
View file @
c4bccd3c
...
@@ -11,11 +11,39 @@
...
@@ -11,11 +11,39 @@
module itertools
module itertools
class itertools.groupby "groupbyobject *" "&groupby_type"
class itertools.groupby "groupbyobject *" "&groupby_type"
class itertools._grouper "_grouperobject *" "&_grouper_type"
class itertools._grouper "_grouperobject *" "&_grouper_type"
class itertools.teedataobject "teedataobject *" "&teedataobject_type"
class itertools._tee "teeobject *" "&tee_type"
class itertools.cycle "cycleobject *" "&cycle_type"
class itertools.dropwhile "dropwhileobject *" "&dropwhile_type"
class itertools.takewhile "takewhileobject *" "&takewhile_type"
class itertools.starmap "starmapobject *" "&starmap_type"
class itertools.chain "chainobject *" "&chain_type"
class itertools.combinations "combinationsobject *" "&combinations_type"
class itertools.combinations_with_replacement "cwr_object *" "&cwr_type"
class itertools.permutations "permutationsobject *" "&permutations_type"
class itertools.accumulate "accumulateobject *" "&accumulate_type"
class itertools.compress "compressobject *" "&compress_type"
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
class itertools.count "countobject *" "&count_type"
[clinic start generated code]*/
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=
9d506f5bb9177570
]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=
ea05c93c6d94726a
]*/
static
PyTypeObject
groupby_type
;
static
PyTypeObject
groupby_type
;
static
PyTypeObject
_grouper_type
;
static
PyTypeObject
_grouper_type
;
static
PyTypeObject
teedataobject_type
;
static
PyTypeObject
tee_type
;
static
PyTypeObject
cycle_type
;
static
PyTypeObject
dropwhile_type
;
static
PyTypeObject
takewhile_type
;
static
PyTypeObject
starmap_type
;
static
PyTypeObject
combinations_type
;
static
PyTypeObject
cwr_type
;
static
PyTypeObject
permutations_type
;
static
PyTypeObject
accumulate_type
;
static
PyTypeObject
compress_type
;
static
PyTypeObject
filterfalse_type
;
static
PyTypeObject
count_type
;
#include "clinic/itertoolsmodule.c.h"
#include "clinic/itertoolsmodule.c.h"
...
@@ -539,18 +567,25 @@ teedataobject_reduce(teedataobject *tdo, PyObject *Py_UNUSED(ignored))
...
@@ -539,18 +567,25 @@ teedataobject_reduce(teedataobject *tdo, PyObject *Py_UNUSED(ignored))
tdo
->
nextlink
?
tdo
->
nextlink
:
Py_None
);
tdo
->
nextlink
?
tdo
->
nextlink
:
Py_None
);
}
}
static
PyTypeObject
teedataobject_type
;
/*[clinic input]
@classmethod
itertools.teedataobject.__new__
iterable as it: object
values: object(subclass_of='&PyList_Type')
next: object
/
Data container common to multiple tee objects.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
teedataobject_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kw
)
itertools_teedataobject_impl
(
PyTypeObject
*
type
,
PyObject
*
it
,
PyObject
*
values
,
PyObject
*
next
)
/*[clinic end generated code: output=3343ceb07e08df5e input=be60f2fabd2b72ba]*/
{
{
teedataobject
*
tdo
;
teedataobject
*
tdo
;
PyObject
*
it
,
*
values
,
*
next
;
Py_ssize_t
i
,
len
;
Py_ssize_t
i
,
len
;
assert
(
type
==
&
teedataobject_type
);
assert
(
type
==
&
teedataobject_type
);
if
(
!
PyArg_ParseTuple
(
args
,
"OO!O"
,
&
it
,
&
PyList_Type
,
&
values
,
&
next
))
return
NULL
;
tdo
=
(
teedataobject
*
)
teedataobject_newinternal
(
it
);
tdo
=
(
teedataobject
*
)
teedataobject_newinternal
(
it
);
if
(
!
tdo
)
if
(
!
tdo
)
...
@@ -592,8 +627,6 @@ static PyMethodDef teedataobject_methods[] = {
...
@@ -592,8 +627,6 @@ static PyMethodDef teedataobject_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
teedataobject_doc
,
"Data container common to multiple tee objects."
);
static
PyTypeObject
teedataobject_type
=
{
static
PyTypeObject
teedataobject_type
=
{
PyVarObject_HEAD_INIT
(
0
,
0
)
/* Must fill in type value later */
PyVarObject_HEAD_INIT
(
0
,
0
)
/* Must fill in type value later */
"itertools._tee_dataobject"
,
/* tp_name */
"itertools._tee_dataobject"
,
/* tp_name */
...
@@ -616,7 +649,7 @@ static PyTypeObject teedataobject_type = {
...
@@ -616,7 +649,7 @@ static PyTypeObject teedataobject_type = {
0
,
/* tp_setattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
teedataobject_doc
,
/* tp_doc */
itertools_teedataobject__doc__
,
/* tp_doc */
(
traverseproc
)
teedataobject_traverse
,
/* tp_traverse */
(
traverseproc
)
teedataobject_traverse
,
/* tp_traverse */
(
inquiry
)
teedataobject_clear
,
/* tp_clear */
(
inquiry
)
teedataobject_clear
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -633,7 +666,7 @@ static PyTypeObject teedataobject_type = {
...
@@ -633,7 +666,7 @@ static PyTypeObject teedataobject_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
teedataobject_new
,
/* tp_new */
itertools_teedataobject
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -716,13 +749,18 @@ done:
...
@@ -716,13 +749,18 @@ done:
return
(
PyObject
*
)
to
;
return
(
PyObject
*
)
to
;
}
}
/*[clinic input]
@classmethod
itertools._tee.__new__
iterable: object
/
Iterator wrapped to make it copyable.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
tee_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kw
)
itertools__tee_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
)
/*[clinic end generated code: output=b02d3fd26c810c3f input=adc0779d2afe37a2]*/
{
{
PyObject
*
iterable
;
if
(
!
PyArg_UnpackTuple
(
args
,
"_tee"
,
1
,
1
,
&
iterable
))
return
NULL
;
return
tee_fromiterable
(
iterable
);
return
tee_fromiterable
(
iterable
);
}
}
...
@@ -771,9 +809,6 @@ tee_setstate(teeobject *to, PyObject *state)
...
@@ -771,9 +809,6 @@ tee_setstate(teeobject *to, PyObject *state)
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
PyDoc_STRVAR
(
teeobject_doc
,
"Iterator wrapped to make it copyable"
);
static
PyMethodDef
tee_methods
[]
=
{
static
PyMethodDef
tee_methods
[]
=
{
{
"__copy__"
,
(
PyCFunction
)
tee_copy
,
METH_NOARGS
,
teecopy_doc
},
{
"__copy__"
,
(
PyCFunction
)
tee_copy
,
METH_NOARGS
,
teecopy_doc
},
{
"__reduce__"
,
(
PyCFunction
)
tee_reduce
,
METH_NOARGS
,
reduce_doc
},
{
"__reduce__"
,
(
PyCFunction
)
tee_reduce
,
METH_NOARGS
,
reduce_doc
},
...
@@ -803,7 +838,7 @@ static PyTypeObject tee_type = {
...
@@ -803,7 +838,7 @@ static PyTypeObject tee_type = {
0
,
/* tp_setattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
teeobject_doc
,
/* tp_doc */
itertools__tee__doc__
,
/* tp_doc */
(
traverseproc
)
tee_traverse
,
/* tp_traverse */
(
traverseproc
)
tee_traverse
,
/* tp_traverse */
(
inquiry
)
tee_clear
,
/* tp_clear */
(
inquiry
)
tee_clear
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -820,19 +855,26 @@ static PyTypeObject tee_type = {
...
@@ -820,19 +855,26 @@ static PyTypeObject tee_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
tee_new
,
/* tp_new */
itertools__tee
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
/*[clinic input]
itertools.tee
iterable: object
n: Py_ssize_t = 2
/
Returns a tuple of n independent iterators.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
tee
(
PyObject
*
self
,
PyObject
*
args
)
itertools_tee_impl
(
PyObject
*
module
,
PyObject
*
iterable
,
Py_ssize_t
n
)
/*[clinic end generated code: output=1c64519cd859c2f0 input=c99a1472c425d66d]*/
{
{
Py_ssize_t
i
,
n
=
2
;
Py_ssize_t
i
;
PyObject
*
it
,
*
iterable
,
*
copyable
,
*
copyfunc
,
*
result
;
PyObject
*
it
,
*
copyable
,
*
copyfunc
,
*
result
;
_Py_IDENTIFIER
(
__copy__
);
_Py_IDENTIFIER
(
__copy__
);
if
(
!
PyArg_ParseTuple
(
args
,
"O|n"
,
&
iterable
,
&
n
))
return
NULL
;
if
(
n
<
0
)
{
if
(
n
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"n must be >= 0"
);
PyErr_SetString
(
PyExc_ValueError
,
"n must be >= 0"
);
return
NULL
;
return
NULL
;
...
@@ -885,9 +927,6 @@ tee(PyObject *self, PyObject *args)
...
@@ -885,9 +927,6 @@ tee(PyObject *self, PyObject *args)
return
result
;
return
result
;
}
}
PyDoc_STRVAR
(
tee_doc
,
"tee(iterable, n=2) --> tuple of n independent iterators."
);
/* cycle object **************************************************************/
/* cycle object **************************************************************/
...
@@ -901,20 +940,22 @@ typedef struct {
...
@@ -901,20 +940,22 @@ typedef struct {
static
PyTypeObject
cycle_type
;
static
PyTypeObject
cycle_type
;
/*[clinic input]
@classmethod
itertools.cycle.__new__
iterable: object
/
Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
cycle_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_cycle_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
)
/*[clinic end generated code: output=f60e5ec17a45b35c input=9d1d84bcf66e908b]*/
{
{
PyObject
*
it
;
PyObject
*
it
;
PyObject
*
iterable
;
PyObject
*
saved
;
PyObject
*
saved
;
cycleobject
*
lz
;
cycleobject
*
lz
;
if
(
type
==
&
cycle_type
&&
!
_PyArg_NoKeywords
(
"cycle"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"cycle"
,
1
,
1
,
&
iterable
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
iterable
);
it
=
PyObject_GetIter
(
iterable
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
...
@@ -1041,12 +1082,6 @@ static PyMethodDef cycle_methods[] = {
...
@@ -1041,12 +1082,6 @@ static PyMethodDef cycle_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
cycle_doc
,
"cycle(iterable) --> cycle object
\n
\
\n
\
Return elements from the iterable until it is exhausted.
\n
\
Then repeat the sequence indefinitely."
);
static
PyTypeObject
cycle_type
=
{
static
PyTypeObject
cycle_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.cycle"
,
/* tp_name */
"itertools.cycle"
,
/* tp_name */
...
@@ -1070,7 +1105,7 @@ static PyTypeObject cycle_type = {
...
@@ -1070,7 +1105,7 @@ static PyTypeObject cycle_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
cycle_doc
,
/* tp_doc */
itertools_cycle__doc__
,
/* tp_doc */
(
traverseproc
)
cycle_traverse
,
/* tp_traverse */
(
traverseproc
)
cycle_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -1087,7 +1122,7 @@ static PyTypeObject cycle_type = {
...
@@ -1087,7 +1122,7 @@ static PyTypeObject cycle_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
cycle_new
,
/* tp_new */
itertools_cycle
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -1103,19 +1138,24 @@ typedef struct {
...
@@ -1103,19 +1138,24 @@ typedef struct {
static
PyTypeObject
dropwhile_type
;
static
PyTypeObject
dropwhile_type
;
/*[clinic input]
@classmethod
itertools.dropwhile.__new__
predicate as func: object
iterable as seq: object
/
Drop items from the iterable while predicate(item) is true.
Afterwards, return every element until the iterable is exhausted.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
dropwhile_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_dropwhile_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
)
/*[clinic end generated code: output=92f9d0d89af149e4 input=d39737147c9f0a26]*/
{
{
PyObject
*
func
,
*
seq
;
PyObject
*
it
;
PyObject
*
it
;
dropwhileobject
*
lz
;
dropwhileobject
*
lz
;
if
(
type
==
&
dropwhile_type
&&
!
_PyArg_NoKeywords
(
"dropwhile"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"dropwhile"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
...
@@ -1209,12 +1249,6 @@ static PyMethodDef dropwhile_methods[] = {
...
@@ -1209,12 +1249,6 @@ static PyMethodDef dropwhile_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
dropwhile_doc
,
"dropwhile(predicate, iterable) --> dropwhile object
\n
\
\n
\
Drop items from the iterable while predicate(item) is true.
\n
\
Afterwards, return every element until the iterable is exhausted."
);
static
PyTypeObject
dropwhile_type
=
{
static
PyTypeObject
dropwhile_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.dropwhile"
,
/* tp_name */
"itertools.dropwhile"
,
/* tp_name */
...
@@ -1238,7 +1272,7 @@ static PyTypeObject dropwhile_type = {
...
@@ -1238,7 +1272,7 @@ static PyTypeObject dropwhile_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
dropwhile_doc
,
/* tp_doc */
itertools_dropwhile__doc__
,
/* tp_doc */
(
traverseproc
)
dropwhile_traverse
,
/* tp_traverse */
(
traverseproc
)
dropwhile_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -1255,7 +1289,7 @@ static PyTypeObject dropwhile_type = {
...
@@ -1255,7 +1289,7 @@ static PyTypeObject dropwhile_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
dropwhile_new
,
/* tp_new */
itertools_dropwhile
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -1271,19 +1305,22 @@ typedef struct {
...
@@ -1271,19 +1305,22 @@ typedef struct {
static
PyTypeObject
takewhile_type
;
static
PyTypeObject
takewhile_type
;
/*[clinic input]
@classmethod
itertools.takewhile.__new__
predicate as func: object
iterable as seq: object
/
Return successive entries from an iterable as long as the predicate evaluates to true for each entry.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
takewhile_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_takewhile_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
)
/*[clinic end generated code: output=bb179ea7864e2ef6 input=ba5255f7519aa119]*/
{
{
PyObject
*
func
,
*
seq
;
PyObject
*
it
;
PyObject
*
it
;
takewhileobject
*
lz
;
takewhileobject
*
lz
;
if
(
type
==
&
takewhile_type
&&
!
_PyArg_NoKeywords
(
"takewhile"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"takewhile"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
...
@@ -1373,11 +1410,6 @@ static PyMethodDef takewhile_reduce_methods[] = {
...
@@ -1373,11 +1410,6 @@ static PyMethodDef takewhile_reduce_methods[] = {
setstate_doc
},
setstate_doc
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
takewhile_doc
,
"takewhile(predicate, iterable) --> takewhile object
\n
\
\n
\
Return successive entries from an iterable as long as the
\n
\
predicate evaluates to true for each entry."
);
static
PyTypeObject
takewhile_type
=
{
static
PyTypeObject
takewhile_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
...
@@ -1402,7 +1434,7 @@ static PyTypeObject takewhile_type = {
...
@@ -1402,7 +1434,7 @@ static PyTypeObject takewhile_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
takewhile_doc
,
/* tp_doc */
itertools_takewhile__doc__
,
/* tp_doc */
(
traverseproc
)
takewhile_traverse
,
/* tp_traverse */
(
traverseproc
)
takewhile_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -1419,7 +1451,7 @@ static PyTypeObject takewhile_type = {
...
@@ -1419,7 +1451,7 @@ static PyTypeObject takewhile_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
takewhile_new
,
/* tp_new */
itertools_takewhile
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -1693,19 +1725,22 @@ typedef struct {
...
@@ -1693,19 +1725,22 @@ typedef struct {
static
PyTypeObject
starmap_type
;
static
PyTypeObject
starmap_type
;
/*[clinic input]
@classmethod
itertools.starmap.__new__
function as func: object
iterable as seq: object
/
Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
starmap_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_starmap_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
)
/*[clinic end generated code: output=79eeb81d452c6e8d input=844766df6a0d4dad]*/
{
{
PyObject
*
func
,
*
seq
;
PyObject
*
it
;
PyObject
*
it
;
starmapobject
*
lz
;
starmapobject
*
lz
;
if
(
type
==
&
starmap_type
&&
!
_PyArg_NoKeywords
(
"starmap"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"starmap"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
...
@@ -1776,12 +1811,6 @@ static PyMethodDef starmap_methods[] = {
...
@@ -1776,12 +1811,6 @@ static PyMethodDef starmap_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
starmap_doc
,
"starmap(function, sequence) --> starmap object
\n
\
\n
\
Return an iterator whose values are returned from the function evaluated
\n
\
with an argument tuple taken from the given sequence."
);
static
PyTypeObject
starmap_type
=
{
static
PyTypeObject
starmap_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.starmap"
,
/* tp_name */
"itertools.starmap"
,
/* tp_name */
...
@@ -1805,7 +1834,7 @@ static PyTypeObject starmap_type = {
...
@@ -1805,7 +1834,7 @@ static PyTypeObject starmap_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
starmap_doc
,
/* tp_doc */
itertools_starmap__doc__
,
/* tp_doc */
(
traverseproc
)
starmap_traverse
,
/* tp_traverse */
(
traverseproc
)
starmap_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -1822,7 +1851,7 @@ static PyTypeObject starmap_type = {
...
@@ -1822,7 +1851,7 @@ static PyTypeObject starmap_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
starmap_new
,
/* tp_new */
itertools_starmap
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -1868,8 +1897,17 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -1868,8 +1897,17 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return
chain_new_internal
(
type
,
source
);
return
chain_new_internal
(
type
,
source
);
}
}
/*[clinic input]
@classmethod
itertools.chain.from_iterable
iterable as arg: object
/
Alternative chain() constructor taking a single iterable argument that evaluates lazily.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
chain_new_from_iterable
(
PyTypeObject
*
type
,
PyObject
*
arg
)
itertools_chain_from_iterable
(
PyTypeObject
*
type
,
PyObject
*
arg
)
/*[clinic end generated code: output=667ae7a7f7b68654 input=72c39e3a2ca3be85]*/
{
{
PyObject
*
source
;
PyObject
*
source
;
...
@@ -1985,15 +2023,8 @@ Return a chain object whose .__next__() method returns elements from the\n\
...
@@ -1985,15 +2023,8 @@ Return a chain object whose .__next__() method returns elements from the\n\
first iterable until it is exhausted, then elements from the next
\n
\
first iterable until it is exhausted, then elements from the next
\n
\
iterable, until all of the iterables are exhausted."
);
iterable, until all of the iterables are exhausted."
);
PyDoc_STRVAR
(
chain_from_iterable_doc
,
"chain.from_iterable(iterable) --> chain object
\n
\
\n
\
Alternate chain() constructor taking a single iterable argument
\n
\
that evaluates lazily."
);
static
PyMethodDef
chain_methods
[]
=
{
static
PyMethodDef
chain_methods
[]
=
{
{
"from_iterable"
,
(
PyCFunction
)
chain_new_from_iterable
,
METH_O
|
METH_CLASS
,
ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF
chain_from_iterable_doc
},
{
"__reduce__"
,
(
PyCFunction
)
chain_reduce
,
METH_NOARGS
,
{
"__reduce__"
,
(
PyCFunction
)
chain_reduce
,
METH_NOARGS
,
reduce_doc
},
reduce_doc
},
{
"__setstate__"
,
(
PyCFunction
)
chain_setstate
,
METH_O
,
{
"__setstate__"
,
(
PyCFunction
)
chain_setstate
,
METH_O
,
...
@@ -2417,21 +2448,27 @@ typedef struct {
...
@@ -2417,21 +2448,27 @@ typedef struct {
static
PyTypeObject
combinations_type
;
static
PyTypeObject
combinations_type
;
/*[clinic input]
@classmethod
itertools.combinations.__new__
iterable: object
r: Py_ssize_t
Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
combinations_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_combinations_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
Py_ssize_t
r
)
/*[clinic end generated code: output=87a689b39c40039c input=06bede09e3da20f8]*/
{
{
combinationsobject
*
co
;
combinationsobject
*
co
;
Py_ssize_t
n
;
Py_ssize_t
n
;
Py_ssize_t
r
;
PyObject
*
pool
=
NULL
;
PyObject
*
pool
=
NULL
;
PyObject
*
iterable
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
i
;
Py_ssize_t
i
;
static
char
*
kwargs
[]
=
{
"iterable"
,
"r"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"On:combinations"
,
kwargs
,
&
iterable
,
&
r
))
return
NULL
;
pool
=
PySequence_Tuple
(
iterable
);
pool
=
PySequence_Tuple
(
iterable
);
if
(
pool
==
NULL
)
if
(
pool
==
NULL
)
...
@@ -2666,12 +2703,6 @@ static PyMethodDef combinations_methods[] = {
...
@@ -2666,12 +2703,6 @@ static PyMethodDef combinations_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
combinations_doc
,
"combinations(iterable, r) --> combinations object
\n
\
\n
\
Return successive r-length combinations of elements in the iterable.
\n\n
\
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"
);
static
PyTypeObject
combinations_type
=
{
static
PyTypeObject
combinations_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.combinations"
,
/* tp_name */
"itertools.combinations"
,
/* tp_name */
...
@@ -2695,7 +2726,7 @@ static PyTypeObject combinations_type = {
...
@@ -2695,7 +2726,7 @@ static PyTypeObject combinations_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
combinations_doc
,
/* tp_doc */
itertools_combinations__doc__
,
/* tp_doc */
(
traverseproc
)
combinations_traverse
,
/* tp_traverse */
(
traverseproc
)
combinations_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -2712,7 +2743,7 @@ static PyTypeObject combinations_type = {
...
@@ -2712,7 +2743,7 @@ static PyTypeObject combinations_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
combinations_new
,
/* tp_new */
itertools_combinations
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -2756,22 +2787,27 @@ typedef struct {
...
@@ -2756,22 +2787,27 @@ typedef struct {
static
PyTypeObject
cwr_type
;
static
PyTypeObject
cwr_type
;
/*[clinic input]
@classmethod
itertools.combinations_with_replacement.__new__
iterable: object
r: Py_ssize_t
Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.
combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC"
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
cwr_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_combinations_with_replacement_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
Py_ssize_t
r
)
/*[clinic end generated code: output=48b26856d4e659ca input=dc2a8c7ba785fad7]*/
{
{
cwrobject
*
co
;
cwrobject
*
co
;
Py_ssize_t
n
;
Py_ssize_t
n
;
Py_ssize_t
r
;
PyObject
*
pool
=
NULL
;
PyObject
*
pool
=
NULL
;
PyObject
*
iterable
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
i
;
Py_ssize_t
i
;
static
char
*
kwargs
[]
=
{
"iterable"
,
"r"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"On:combinations_with_replacement"
,
kwargs
,
&
iterable
,
&
r
))
return
NULL
;
pool
=
PySequence_Tuple
(
iterable
);
pool
=
PySequence_Tuple
(
iterable
);
if
(
pool
==
NULL
)
if
(
pool
==
NULL
)
...
@@ -2996,13 +3032,6 @@ static PyMethodDef cwr_methods[] = {
...
@@ -2996,13 +3032,6 @@ static PyMethodDef cwr_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
cwr_doc
,
"combinations_with_replacement(iterable, r) --> combinations_with_replacement object
\n
\
\n
\
Return successive r-length combinations of elements in the iterable
\n
\
allowing individual elements to have successive repeats.
\n
\
combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC"
);
static
PyTypeObject
cwr_type
=
{
static
PyTypeObject
cwr_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.combinations_with_replacement"
,
/* tp_name */
"itertools.combinations_with_replacement"
,
/* tp_name */
...
@@ -3026,7 +3055,7 @@ static PyTypeObject cwr_type = {
...
@@ -3026,7 +3055,7 @@ static PyTypeObject cwr_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
cwr_doc
,
/* tp_doc */
itertools_combinations_with_replacement__doc__
,
/* tp_doc */
(
traverseproc
)
cwr_traverse
,
/* tp_traverse */
(
traverseproc
)
cwr_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -3043,7 +3072,7 @@ static PyTypeObject cwr_type = {
...
@@ -3043,7 +3072,7 @@ static PyTypeObject cwr_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
cwr_new
,
/* tp_new */
itertools_combinations_with_replacement
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -3085,23 +3114,28 @@ typedef struct {
...
@@ -3085,23 +3114,28 @@ typedef struct {
static
PyTypeObject
permutations_type
;
static
PyTypeObject
permutations_type
;
/*[clinic input]
@classmethod
itertools.permutations.__new__
iterable: object
r as robj: object = None
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
permutations_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_permutations_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
PyObject
*
robj
)
/*[clinic end generated code: output=296a72fa76d620ea input=57d0170a4ac0ec7a]*/
{
{
permutationsobject
*
po
;
permutationsobject
*
po
;
Py_ssize_t
n
;
Py_ssize_t
n
;
Py_ssize_t
r
;
Py_ssize_t
r
;
PyObject
*
robj
=
Py_None
;
PyObject
*
pool
=
NULL
;
PyObject
*
pool
=
NULL
;
PyObject
*
iterable
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
*
indices
=
NULL
;
Py_ssize_t
*
cycles
=
NULL
;
Py_ssize_t
*
cycles
=
NULL
;
Py_ssize_t
i
;
Py_ssize_t
i
;
static
char
*
kwargs
[]
=
{
"iterable"
,
"r"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:permutations"
,
kwargs
,
&
iterable
,
&
robj
))
return
NULL
;
pool
=
PySequence_Tuple
(
iterable
);
pool
=
PySequence_Tuple
(
iterable
);
if
(
pool
==
NULL
)
if
(
pool
==
NULL
)
...
@@ -3389,12 +3423,6 @@ static PyMethodDef permuations_methods[] = {
...
@@ -3389,12 +3423,6 @@ static PyMethodDef permuations_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
permutations_doc
,
"permutations(iterable[, r]) --> permutations object
\n
\
\n
\
Return successive r-length permutations of elements in the iterable.
\n\n
\
permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"
);
static
PyTypeObject
permutations_type
=
{
static
PyTypeObject
permutations_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.permutations"
,
/* tp_name */
"itertools.permutations"
,
/* tp_name */
...
@@ -3418,7 +3446,7 @@ static PyTypeObject permutations_type = {
...
@@ -3418,7 +3446,7 @@ static PyTypeObject permutations_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
permutations_doc
,
/* tp_doc */
itertools_permutations__doc__
,
/* tp_doc */
(
traverseproc
)
permutations_traverse
,
/* tp_traverse */
(
traverseproc
)
permutations_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -3435,10 +3463,11 @@ static PyTypeObject permutations_type = {
...
@@ -3435,10 +3463,11 @@ static PyTypeObject permutations_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
permutations_new
,
/* tp_new */
itertools_permutations
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
/* accumulate object ********************************************************/
/* accumulate object ********************************************************/
typedef
struct
{
typedef
struct
{
...
@@ -3450,18 +3479,22 @@ typedef struct {
...
@@ -3450,18 +3479,22 @@ typedef struct {
static
PyTypeObject
accumulate_type
;
static
PyTypeObject
accumulate_type
;
/*[clinic input]
@classmethod
itertools.accumulate.__new__
iterable: object
func as binop: object = None
Return series of accumulated sums (or other binary function results).
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
accumulate_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_accumulate_impl
(
PyTypeObject
*
type
,
PyObject
*
iterable
,
PyObject
*
binop
)
/*[clinic end generated code: output=514d0fb30ba14d55 input=6d9d16aaa1d3cbfc]*/
{
{
static
char
*
kwargs
[]
=
{
"iterable"
,
"func"
,
NULL
};
PyObject
*
iterable
;
PyObject
*
it
;
PyObject
*
it
;
PyObject
*
binop
=
Py_None
;
accumulateobject
*
lz
;
accumulateobject
*
lz
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:accumulate"
,
kwargs
,
&
iterable
,
&
binop
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
iterable
);
it
=
PyObject_GetIter
(
iterable
);
...
@@ -3572,11 +3605,6 @@ static PyMethodDef accumulate_methods[] = {
...
@@ -3572,11 +3605,6 @@ static PyMethodDef accumulate_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
accumulate_doc
,
"accumulate(iterable[, func]) --> accumulate object
\n
\
\n
\
Return series of accumulated sums (or other binary function results)."
);
static
PyTypeObject
accumulate_type
=
{
static
PyTypeObject
accumulate_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.accumulate"
,
/* tp_name */
"itertools.accumulate"
,
/* tp_name */
...
@@ -3600,7 +3628,7 @@ static PyTypeObject accumulate_type = {
...
@@ -3600,7 +3628,7 @@ static PyTypeObject accumulate_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
accumulate_doc
,
/* tp_doc */
itertools_accumulate__doc__
,
/* tp_doc */
(
traverseproc
)
accumulate_traverse
,
/* tp_traverse */
(
traverseproc
)
accumulate_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -3617,7 +3645,7 @@ static PyTypeObject accumulate_type = {
...
@@ -3617,7 +3645,7 @@ static PyTypeObject accumulate_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
accumulate_new
,
/* tp_new */
itertools_accumulate
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -3639,16 +3667,23 @@ typedef struct {
...
@@ -3639,16 +3667,23 @@ typedef struct {
static
PyTypeObject
compress_type
;
static
PyTypeObject
compress_type
;
/*[clinic input]
@classmethod
itertools.compress.__new__
data as seq1: object
selectors as seq2: object
Return data elements corresponding to true selector elements.
Forms a shorter iterator from selected data elements using the selectors to
choose the data elements.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
compress_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_compress_impl
(
PyTypeObject
*
type
,
PyObject
*
seq1
,
PyObject
*
seq2
)
/*[clinic end generated code: output=7e67157212ed09e0 input=79596d7cd20c77e5]*/
{
{
PyObject
*
seq1
,
*
seq2
;
PyObject
*
data
=
NULL
,
*
selectors
=
NULL
;
PyObject
*
data
=
NULL
,
*
selectors
=
NULL
;
compressobject
*
lz
;
compressobject
*
lz
;
static
char
*
kwargs
[]
=
{
"data"
,
"selectors"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"OO:compress"
,
kwargs
,
&
seq1
,
&
seq2
))
return
NULL
;
data
=
PyObject_GetIter
(
seq1
);
data
=
PyObject_GetIter
(
seq1
);
if
(
data
==
NULL
)
if
(
data
==
NULL
)
...
@@ -3737,13 +3772,6 @@ static PyMethodDef compress_methods[] = {
...
@@ -3737,13 +3772,6 @@ static PyMethodDef compress_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
compress_doc
,
"compress(data, selectors) --> iterator over selected data
\n
\
\n
\
Return data elements corresponding to true selector elements.
\n
\
Forms a shorter iterator from selected data elements using the
\n
\
selectors to choose the data elements."
);
static
PyTypeObject
compress_type
=
{
static
PyTypeObject
compress_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.compress"
,
/* tp_name */
"itertools.compress"
,
/* tp_name */
...
@@ -3767,7 +3795,7 @@ static PyTypeObject compress_type = {
...
@@ -3767,7 +3795,7 @@ static PyTypeObject compress_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
compress_doc
,
/* tp_doc */
itertools_compress__doc__
,
/* tp_doc */
(
traverseproc
)
compress_traverse
,
/* tp_traverse */
(
traverseproc
)
compress_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -3784,7 +3812,7 @@ static PyTypeObject compress_type = {
...
@@ -3784,7 +3812,7 @@ static PyTypeObject compress_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
compress_new
,
/* tp_new */
itertools_compress
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -3799,20 +3827,24 @@ typedef struct {
...
@@ -3799,20 +3827,24 @@ typedef struct {
static
PyTypeObject
filterfalse_type
;
static
PyTypeObject
filterfalse_type
;
/*[clinic input]
@classmethod
itertools.filterfalse.__new__
function as func: object
iterable as seq: object
/
Return those items of iterable for which function(item) is false.
If function is None, return the items that are false.
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
filterfalse_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_filterfalse_impl
(
PyTypeObject
*
type
,
PyObject
*
func
,
PyObject
*
seq
)
/*[clinic end generated code: output=55f87eab9fc0484e input=2d684a2c66f99cde]*/
{
{
PyObject
*
func
,
*
seq
;
PyObject
*
it
;
PyObject
*
it
;
filterfalseobject
*
lz
;
filterfalseobject
*
lz
;
if
(
type
==
&
filterfalse_type
&&
!
_PyArg_NoKeywords
(
"filterfalse"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"filterfalse"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
/* Get iterator. */
/* Get iterator. */
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
if
(
it
==
NULL
)
if
(
it
==
NULL
)
...
@@ -3894,12 +3926,6 @@ static PyMethodDef filterfalse_methods[] = {
...
@@ -3894,12 +3926,6 @@ static PyMethodDef filterfalse_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
filterfalse_doc
,
"filterfalse(function or None, sequence) --> filterfalse object
\n
\
\n
\
Return those items of sequence for which function(item) is false.
\n
\
If function is None, return the items that are false."
);
static
PyTypeObject
filterfalse_type
=
{
static
PyTypeObject
filterfalse_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.filterfalse"
,
/* tp_name */
"itertools.filterfalse"
,
/* tp_name */
...
@@ -3923,7 +3949,7 @@ static PyTypeObject filterfalse_type = {
...
@@ -3923,7 +3949,7 @@ static PyTypeObject filterfalse_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
filterfalse_doc
,
/* tp_doc */
itertools_filterfalse__doc__
,
/* tp_doc */
(
traverseproc
)
filterfalse_traverse
,
/* tp_traverse */
(
traverseproc
)
filterfalse_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -3940,7 +3966,7 @@ static PyTypeObject filterfalse_type = {
...
@@ -3940,7 +3966,7 @@ static PyTypeObject filterfalse_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
filterfalse_new
,
/* tp_new */
itertools_filterfalse
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -3973,20 +3999,30 @@ slow_mode: when cnt == PY_SSIZE_T_MAX, step is not int(1), or cnt is a float.
...
@@ -3973,20 +3999,30 @@ slow_mode: when cnt == PY_SSIZE_T_MAX, step is not int(1), or cnt is a float.
static
PyTypeObject
count_type
;
static
PyTypeObject
count_type
;
/*[clinic input]
@classmethod
itertools.count.__new__
start as long_cnt: object(c_default="NULL") = 0
step as long_step: object(c_default="NULL") = 1
Return a count object whose .__next__() method returns consecutive values.
Equivalent to:
def count(firstval=0, step=1):
x = firstval
while 1:
yield x
x += step
[clinic start generated code]*/
static
PyObject
*
static
PyObject
*
count_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
itertools_count_impl
(
PyTypeObject
*
type
,
PyObject
*
long_cnt
,
PyObject
*
long_step
)
/*[clinic end generated code: output=09a9250aebd00b1c input=d7a85eec18bfcd94]*/
{
{
countobject
*
lz
;
countobject
*
lz
;
int
fast_mode
;
int
fast_mode
;
Py_ssize_t
cnt
=
0
;
Py_ssize_t
cnt
=
0
;
PyObject
*
long_cnt
=
NULL
;
PyObject
*
long_step
=
NULL
;
long
step
;
long
step
;
static
char
*
kwlist
[]
=
{
"start"
,
"step"
,
0
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OO:count"
,
kwlist
,
&
long_cnt
,
&
long_step
))
return
NULL
;
if
((
long_cnt
!=
NULL
&&
!
PyNumber_Check
(
long_cnt
))
||
if
((
long_cnt
!=
NULL
&&
!
PyNumber_Check
(
long_cnt
))
||
(
long_step
!=
NULL
&&
!
PyNumber_Check
(
long_step
)))
{
(
long_step
!=
NULL
&&
!
PyNumber_Check
(
long_step
)))
{
...
@@ -4139,17 +4175,6 @@ static PyMethodDef count_methods[] = {
...
@@ -4139,17 +4175,6 @@ static PyMethodDef count_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
PyDoc_STRVAR
(
count_doc
,
"count(start=0, step=1) --> count object
\n
\
\n
\
Return a count object whose .__next__() method returns consecutive values.
\n
\
Equivalent to:
\n\n
\
def count(firstval=0, step=1):
\n
\
x = firstval
\n
\
while 1:
\n
\
yield x
\n
\
x += step
\n
"
);
static
PyTypeObject
count_type
=
{
static
PyTypeObject
count_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.count"
,
/* tp_name */
"itertools.count"
,
/* tp_name */
...
@@ -4173,7 +4198,7 @@ static PyTypeObject count_type = {
...
@@ -4173,7 +4198,7 @@ static PyTypeObject count_type = {
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
count_doc
,
/* tp_doc */
itertools_count__doc__
,
/* tp_doc */
(
traverseproc
)
count_traverse
,
/* tp_traverse */
(
traverseproc
)
count_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
@@ -4190,7 +4215,7 @@ static PyTypeObject count_type = {
...
@@ -4190,7 +4215,7 @@ static PyTypeObject count_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_alloc */
count_new
,
/* tp_new */
itertools_count
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
...
@@ -4349,6 +4374,7 @@ static PyTypeObject repeat_type = {
...
@@ -4349,6 +4374,7 @@ static PyTypeObject repeat_type = {
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
/* ziplongest object *********************************************************/
/* ziplongest object *********************************************************/
typedef
struct
{
typedef
struct
{
...
@@ -4619,6 +4645,7 @@ static PyTypeObject ziplongest_type = {
...
@@ -4619,6 +4645,7 @@ static PyTypeObject ziplongest_type = {
PyObject_GC_Del
,
/* tp_free */
PyObject_GC_Del
,
/* tp_free */
};
};
/* module level code ********************************************************/
/* module level code ********************************************************/
PyDoc_STRVAR
(
module_doc
,
PyDoc_STRVAR
(
module_doc
,
...
@@ -4653,7 +4680,7 @@ combinations_with_replacement(p, r)\n\
...
@@ -4653,7 +4680,7 @@ combinations_with_replacement(p, r)\n\
static
PyMethodDef
module_methods
[]
=
{
static
PyMethodDef
module_methods
[]
=
{
{
"tee"
,
(
PyCFunction
)
tee
,
METH_VARARGS
,
tee_doc
},
ITERTOOLS_TEE_METHODDEF
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment