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
84492df4
Commit
84492df4
authored
Mar 13, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ifilterfalse() to filterfalse() and izip_longest() to zip_longest().
parent
4c350ca0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
93 deletions
+93
-93
Doc/library/itertools.rst
Doc/library/itertools.rst
+7
-7
Lib/filecmp.py
Lib/filecmp.py
+4
-4
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+41
-41
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+41
-41
No files found.
Doc/library/itertools.rst
View file @
84492df4
...
...
@@ -233,13 +233,13 @@ loops that truncate the stream.
self.currkey = self.keyfunc(self.currvalue)
.. function::
i
filterfalse(predicate, iterable)
.. function:: filterfalse(predicate, iterable)
Make an iterator that filters elements from iterable returning only those for
which the predicate is ``False``. If *predicate* is ``None``, return the items
that are false. Equivalent to::
def
i
filterfalse(predicate, iterable):
def filterfalse(predicate, iterable):
if predicate is None:
predicate = bool
for x in iterable:
...
...
@@ -292,16 +292,16 @@ loops that truncate the stream.
:func:`izip` should only be used with unequal length inputs when you don't
care about trailing, unmatched values from the longer iterables. If those
values are important, use :func:`
i
zip_longest` instead.
values are important, use :func:`zip_longest` instead.
.. function::
i
zip_longest(*iterables[, fillvalue])
.. function:: zip_longest(*iterables[, fillvalue])
Make an iterator that aggregates elements from each of the iterables. If the
iterables are of uneven length, missing values are filled-in with *fillvalue*.
Iteration continues until the longest iterable is exhausted. Equivalent to::
def
i
zip_longest(*args, **kwds):
def zip_longest(*args, **kwds):
fillvalue = kwds.get('fillvalue')
def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
yield counter() # yields the fillvalue, or raises IndexError
...
...
@@ -313,7 +313,7 @@ loops that truncate the stream.
except IndexError:
pass
If one of the iterables is potentially infinite, then the :func:`
i
zip_longest`
If one of the iterables is potentially infinite, then the :func:`zip_longest`
function should be wrapped with something that limits the number of calls (for
example :func:`islice` or :func:`takewhile`).
...
...
@@ -568,7 +568,7 @@ which incur interpreter overhead. ::
def all(seq, pred=None):
"Returns True if pred(x) is true for every element in the iterable"
for elem in
i
filterfalse(pred, seq):
for elem in filterfalse(pred, seq):
return False
return True
...
...
Lib/filecmp.py
View file @
84492df4
...
...
@@ -12,7 +12,7 @@ Functions:
import
os
import
stat
import
warnings
from
itertools
import
i
filterfalse
,
izip
from
itertools
import
filterfalse
,
izip
__all__
=
[
"cmp"
,
"dircmp"
,
"cmpfiles"
]
...
...
@@ -133,8 +133,8 @@ class dircmp:
a
=
dict
(
izip
(
map
(
os
.
path
.
normcase
,
self
.
left_list
),
self
.
left_list
))
b
=
dict
(
izip
(
map
(
os
.
path
.
normcase
,
self
.
right_list
),
self
.
right_list
))
self
.
common
=
list
(
map
(
a
.
__getitem__
,
filter
(
b
.
__contains__
,
a
)))
self
.
left_only
=
list
(
map
(
a
.
__getitem__
,
i
filterfalse
(
b
.
__contains__
,
a
)))
self
.
right_only
=
list
(
map
(
b
.
__getitem__
,
i
filterfalse
(
a
.
__contains__
,
b
)))
self
.
left_only
=
list
(
map
(
a
.
__getitem__
,
filterfalse
(
b
.
__contains__
,
a
)))
self
.
right_only
=
list
(
map
(
b
.
__getitem__
,
filterfalse
(
a
.
__contains__
,
b
)))
def
phase2
(
self
):
# Distinguish files, directories, funnies
self
.
common_dirs
=
[]
...
...
@@ -276,7 +276,7 @@ def _cmp(a, b, sh, abs=abs, cmp=cmp):
# Return a copy with items that occur in skip removed.
#
def
_filter
(
flist
,
skip
):
return
list
(
i
filterfalse
(
skip
.
__contains__
,
flist
))
return
list
(
filterfalse
(
skip
.
__contains__
,
flist
))
# Demonstration and testing.
...
...
Lib/test/test_itertools.py
View file @
84492df4
...
...
@@ -324,16 +324,16 @@ class TestBasicOps(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
ifilter
,
isEven
,
3
)
self
.
assertRaises
(
TypeError
,
next
,
ifilter
(
range
(
6
),
range
(
6
)))
def
test_
i
filterfalse
(
self
):
self
.
assertEqual
(
list
(
i
filterfalse
(
isEven
,
range
(
6
))),
[
1
,
3
,
5
])
self
.
assertEqual
(
list
(
i
filterfalse
(
None
,
[
0
,
1
,
0
,
2
,
0
])),
[
0
,
0
,
0
])
self
.
assertEqual
(
list
(
i
filterfalse
(
bool
,
[
0
,
1
,
0
,
2
,
0
])),
[
0
,
0
,
0
])
self
.
assertEqual
(
take
(
4
,
i
filterfalse
(
isEven
,
count
())),
[
1
,
3
,
5
,
7
])
self
.
assertRaises
(
TypeError
,
i
filterfalse
)
self
.
assertRaises
(
TypeError
,
i
filterfalse
,
lambda
x
:
x
)
self
.
assertRaises
(
TypeError
,
i
filterfalse
,
lambda
x
:
x
,
range
(
6
),
7
)
self
.
assertRaises
(
TypeError
,
i
filterfalse
,
isEven
,
3
)
self
.
assertRaises
(
TypeError
,
next
,
i
filterfalse
(
range
(
6
),
range
(
6
)))
def
test_filterfalse
(
self
):
self
.
assertEqual
(
list
(
filterfalse
(
isEven
,
range
(
6
))),
[
1
,
3
,
5
])
self
.
assertEqual
(
list
(
filterfalse
(
None
,
[
0
,
1
,
0
,
2
,
0
])),
[
0
,
0
,
0
])
self
.
assertEqual
(
list
(
filterfalse
(
bool
,
[
0
,
1
,
0
,
2
,
0
])),
[
0
,
0
,
0
])
self
.
assertEqual
(
take
(
4
,
filterfalse
(
isEven
,
count
())),
[
1
,
3
,
5
,
7
])
self
.
assertRaises
(
TypeError
,
filterfalse
)
self
.
assertRaises
(
TypeError
,
filterfalse
,
lambda
x
:
x
)
self
.
assertRaises
(
TypeError
,
filterfalse
,
lambda
x
:
x
,
range
(
6
),
7
)
self
.
assertRaises
(
TypeError
,
filterfalse
,
isEven
,
3
)
self
.
assertRaises
(
TypeError
,
next
,
filterfalse
(
range
(
6
),
range
(
6
)))
def
test_izip
(
self
):
# XXX This is rather silly now that builtin zip() calls izip()...
...
...
@@ -366,25 +366,25 @@ class TestBasicOps(unittest.TestCase):
]:
target
=
[
tuple
([
arg
[
i
]
if
i
<
len
(
arg
)
else
None
for
arg
in
args
])
for
i
in
range
(
max
(
map
(
len
,
args
)))]
self
.
assertEqual
(
list
(
i
zip_longest
(
*
args
)),
target
)
self
.
assertEqual
(
list
(
i
zip_longest
(
*
args
,
**
{})),
target
)
self
.
assertEqual
(
list
(
zip_longest
(
*
args
)),
target
)
self
.
assertEqual
(
list
(
zip_longest
(
*
args
,
**
{})),
target
)
target
=
[
tuple
((
e
is
None
and
'X'
or
e
)
for
e
in
t
)
for
t
in
target
]
# Replace None fills with 'X'
self
.
assertEqual
(
list
(
i
zip_longest
(
*
args
,
**
dict
(
fillvalue
=
'X'
))),
target
)
self
.
assertEqual
(
list
(
zip_longest
(
*
args
,
**
dict
(
fillvalue
=
'X'
))),
target
)
self
.
assertEqual
(
take
(
3
,
i
zip_longest
(
'abcdef'
,
count
())),
list
(
zip
(
'abcdef'
,
range
(
3
))))
# take 3 from infinite input
self
.
assertEqual
(
take
(
3
,
zip_longest
(
'abcdef'
,
count
())),
list
(
zip
(
'abcdef'
,
range
(
3
))))
# take 3 from infinite input
self
.
assertEqual
(
list
(
i
zip_longest
()),
list
(
zip
()))
self
.
assertEqual
(
list
(
i
zip_longest
([])),
list
(
zip
([])))
self
.
assertEqual
(
list
(
i
zip_longest
(
'abcdef'
)),
list
(
zip
(
'abcdef'
)))
self
.
assertEqual
(
list
(
zip_longest
()),
list
(
zip
()))
self
.
assertEqual
(
list
(
zip_longest
([])),
list
(
zip
([])))
self
.
assertEqual
(
list
(
zip_longest
(
'abcdef'
)),
list
(
zip
(
'abcdef'
)))
self
.
assertEqual
(
list
(
i
zip_longest
(
'abc'
,
'defg'
,
**
{})),
self
.
assertEqual
(
list
(
zip_longest
(
'abc'
,
'defg'
,
**
{})),
list
(
izip
(
list
(
'abc'
)
+
[
None
],
'defg'
)))
# empty keyword dict
self
.
assertRaises
(
TypeError
,
i
zip_longest
,
3
)
self
.
assertRaises
(
TypeError
,
i
zip_longest
,
range
(
3
),
3
)
self
.
assertRaises
(
TypeError
,
zip_longest
,
3
)
self
.
assertRaises
(
TypeError
,
zip_longest
,
range
(
3
),
3
)
for
stmt
in
[
"
i
zip_longest('abc', fv=1)"
,
"
i
zip_longest('abc', fillvalue=1, bogus_keyword=None)"
,
"zip_longest('abc', fv=1)"
,
"zip_longest('abc', fillvalue=1, bogus_keyword=None)"
,
]:
try
:
eval
(
stmt
,
globals
(),
locals
())
...
...
@@ -394,13 +394,13 @@ class TestBasicOps(unittest.TestCase):
self
.
fail
(
'Did not raise Type in: '
+
stmt
)
# Check tuple re-use (implementation detail)
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
i
zip_longest
(
'abc'
,
'def'
)],
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
list
(
zip
(
'abc'
,
'def'
)))
self
.
assertEqual
([
pair
for
pair
in
i
zip_longest
(
'abc'
,
'def'
)],
self
.
assertEqual
([
pair
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
list
(
zip
(
'abc'
,
'def'
)))
ids
=
list
(
map
(
id
,
i
zip_longest
(
'abc'
,
'def'
)))
ids
=
list
(
map
(
id
,
zip_longest
(
'abc'
,
'def'
)))
self
.
assertEqual
(
min
(
ids
),
max
(
ids
))
ids
=
list
(
map
(
id
,
list
(
i
zip_longest
(
'abc'
,
'def'
))))
ids
=
list
(
map
(
id
,
list
(
zip_longest
(
'abc'
,
'def'
))))
self
.
assertEqual
(
len
(
dict
.
fromkeys
(
ids
)),
len
(
ids
))
def
test_product
(
self
):
...
...
@@ -659,7 +659,7 @@ class TestBasicOps(unittest.TestCase):
self
.
assertRaises
(
StopIteration
,
next
,
repeat
(
None
,
0
))
for
f
in
(
ifilter
,
i
filterfalse
,
imap
,
takewhile
,
dropwhile
,
starmap
):
for
f
in
(
ifilter
,
filterfalse
,
imap
,
takewhile
,
dropwhile
,
starmap
):
self
.
assertRaises
(
StopIteration
,
next
,
f
(
lambda
x
:
x
,
[]))
self
.
assertRaises
(
StopIteration
,
next
,
f
(
lambda
x
:
x
,
StopNow
()))
...
...
@@ -690,9 +690,9 @@ class TestGC(unittest.TestCase):
a
=
[]
self
.
makecycle
(
ifilter
(
lambda
x
:
True
,
[
a
]
*
2
),
a
)
def
test_
i
filterfalse
(
self
):
def
test_filterfalse
(
self
):
a
=
[]
self
.
makecycle
(
i
filterfalse
(
lambda
x
:
False
,
a
),
a
)
self
.
makecycle
(
filterfalse
(
lambda
x
:
False
,
a
),
a
)
def
test_izip
(
self
):
a
=
[]
...
...
@@ -840,14 +840,14 @@ class TestVariousIteratorArgs(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
ifilter
,
isEven
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
list
,
ifilter
(
isEven
,
E
(
s
)))
def
test_
i
filterfalse
(
self
):
def
test_filterfalse
(
self
):
for
s
in
(
range
(
10
),
range
(
0
),
range
(
1000
),
(
7
,
11
),
range
(
2000
,
2200
,
5
)):
for
g
in
(
G
,
I
,
Ig
,
S
,
L
,
R
):
self
.
assertEqual
(
list
(
i
filterfalse
(
isEven
,
g
(
s
))),
self
.
assertEqual
(
list
(
filterfalse
(
isEven
,
g
(
s
))),
[
x
for
x
in
g
(
s
)
if
isOdd
(
x
)])
self
.
assertRaises
(
TypeError
,
i
filterfalse
,
isEven
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
i
filterfalse
,
isEven
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
list
,
i
filterfalse
(
isEven
,
E
(
s
)))
self
.
assertRaises
(
TypeError
,
filterfalse
,
isEven
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
filterfalse
,
isEven
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
list
,
filterfalse
(
isEven
,
E
(
s
)))
def
test_izip
(
self
):
for
s
in
(
"123"
,
""
,
range
(
1000
),
(
'do'
,
1.2
),
range
(
2000
,
2200
,
5
)):
...
...
@@ -861,11 +861,11 @@ class TestVariousIteratorArgs(unittest.TestCase):
def
test_iziplongest
(
self
):
for
s
in
(
"123"
,
""
,
range
(
1000
),
(
'do'
,
1.2
),
range
(
2000
,
2200
,
5
)):
for
g
in
(
G
,
I
,
Ig
,
S
,
L
,
R
):
self
.
assertEqual
(
list
(
i
zip_longest
(
g
(
s
))),
list
(
zip
(
g
(
s
))))
self
.
assertEqual
(
list
(
i
zip_longest
(
g
(
s
),
g
(
s
))),
list
(
zip
(
g
(
s
),
g
(
s
))))
self
.
assertRaises
(
TypeError
,
i
zip_longest
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
i
zip_longest
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
list
,
i
zip_longest
(
E
(
s
)))
self
.
assertEqual
(
list
(
zip_longest
(
g
(
s
))),
list
(
zip
(
g
(
s
))))
self
.
assertEqual
(
list
(
zip_longest
(
g
(
s
),
g
(
s
))),
list
(
zip
(
g
(
s
),
g
(
s
))))
self
.
assertRaises
(
TypeError
,
zip_longest
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
zip_longest
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
list
,
zip_longest
(
E
(
s
)))
def
test_imap
(
self
):
for
s
in
(
range
(
10
),
range
(
0
),
range
(
100
),
(
7
,
11
),
range
(
20
,
50
,
5
)):
...
...
@@ -1001,7 +1001,7 @@ class RegressionTests(unittest.TestCase):
class
SubclassWithKwargsTest
(
unittest
.
TestCase
):
def
test_keywords_in_subclass
(
self
):
# count is not subclassable...
for
cls
in
(
repeat
,
izip
,
ifilter
,
i
filterfalse
,
chain
,
imap
,
for
cls
in
(
repeat
,
izip
,
ifilter
,
filterfalse
,
chain
,
imap
,
starmap
,
islice
,
takewhile
,
dropwhile
,
cycle
):
class
Subclass
(
cls
):
def
__init__
(
self
,
newarg
=
None
,
*
args
):
...
...
@@ -1085,7 +1085,7 @@ Samuele
>>> def all(seq, pred=None):
... "Returns True if pred(x) is true for every element in the iterable"
... for elem in
i
filterfalse(pred, seq):
... for elem in filterfalse(pred, seq):
... return False
... return True
...
...
Modules/itertoolsmodule.c
View file @
84492df4
...
...
@@ -2059,28 +2059,28 @@ static PyTypeObject combinations_type = {
};
/*
i
filterfalse object ************************************************************/
/* filterfalse object ************************************************************/
typedef
struct
{
PyObject_HEAD
PyObject
*
func
;
PyObject
*
it
;
}
i
filterfalseobject
;
}
filterfalseobject
;
static
PyTypeObject
i
filterfalse_type
;
static
PyTypeObject
filterfalse_type
;
static
PyObject
*
i
filterfalse_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
filterfalse_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
PyObject
*
func
,
*
seq
;
PyObject
*
it
;
i
filterfalseobject
*
lz
;
filterfalseobject
*
lz
;
if
(
type
==
&
i
filterfalse_type
&&
!
_PyArg_NoKeywords
(
"
i
filterfalse()"
,
kwds
))
if
(
type
==
&
filterfalse_type
&&
!
_PyArg_NoKeywords
(
"filterfalse()"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"
i
filterfalse"
,
2
,
2
,
&
func
,
&
seq
))
if
(
!
PyArg_UnpackTuple
(
args
,
"filterfalse"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
/* Get iterator. */
...
...
@@ -2088,8 +2088,8 @@ ifilterfalse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
it
==
NULL
)
return
NULL
;
/* create
i
filterfalseobject structure */
lz
=
(
i
filterfalseobject
*
)
type
->
tp_alloc
(
type
,
0
);
/* create filterfalseobject structure */
lz
=
(
filterfalseobject
*
)
type
->
tp_alloc
(
type
,
0
);
if
(
lz
==
NULL
)
{
Py_DECREF
(
it
);
return
NULL
;
...
...
@@ -2102,7 +2102,7 @@ ifilterfalse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static
void
ifilterfalse_dealloc
(
i
filterfalseobject
*
lz
)
filterfalse_dealloc
(
filterfalseobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_XDECREF
(
lz
->
func
);
...
...
@@ -2111,7 +2111,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz)
}
static
int
ifilterfalse_traverse
(
i
filterfalseobject
*
lz
,
visitproc
visit
,
void
*
arg
)
filterfalse_traverse
(
filterfalseobject
*
lz
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
lz
->
it
);
Py_VISIT
(
lz
->
func
);
...
...
@@ -2119,7 +2119,7 @@ ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg)
}
static
PyObject
*
ifilterfalse_next
(
i
filterfalseobject
*
lz
)
filterfalse_next
(
filterfalseobject
*
lz
)
{
PyObject
*
item
;
PyObject
*
it
=
lz
->
it
;
...
...
@@ -2152,19 +2152,19 @@ ifilterfalse_next(ifilterfalseobject *lz)
}
}
PyDoc_STRVAR
(
i
filterfalse_doc
,
"
ifilterfalse(function or None, sequence) --> i
filterfalse object
\n
\
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
i
filterfalse_type
=
{
static
PyTypeObject
filterfalse_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.
i
filterfalse"
,
/* tp_name */
sizeof
(
i
filterfalseobject
),
/* tp_basicsize */
"itertools.filterfalse"
,
/* tp_name */
sizeof
(
filterfalseobject
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
i
filterfalse_dealloc
,
/* tp_dealloc */
(
destructor
)
filterfalse_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
...
...
@@ -2181,13 +2181,13 @@ static PyTypeObject ifilterfalse_type = {
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
i
filterfalse_doc
,
/* tp_doc */
(
traverseproc
)
i
filterfalse_traverse
,
/* tp_traverse */
filterfalse_doc
,
/* tp_doc */
(
traverseproc
)
filterfalse_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
i
filterfalse_next
,
/* tp_iternext */
(
iternextfunc
)
filterfalse_next
,
/* tp_iternext */
0
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
...
...
@@ -2198,7 +2198,7 @@ static PyTypeObject ifilterfalse_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
i
filterfalse_new
,
/* tp_new */
filterfalse_new
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
};
...
...
@@ -2691,7 +2691,7 @@ typedef struct {
static
PyTypeObject
iziplongest_type
;
static
PyObject
*
i
zip_longest_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
zip_longest_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
iziplongestobject
*
lz
;
Py_ssize_t
i
;
...
...
@@ -2704,7 +2704,7 @@ izip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
fillvalue
=
PyDict_GetItemString
(
kwds
,
"fillvalue"
);
if
(
fillvalue
==
NULL
||
PyDict_Size
(
kwds
)
>
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"
i
zip_longest() got an unexpected keyword argument"
);
"zip_longest() got an unexpected keyword argument"
);
return
NULL
;
}
}
...
...
@@ -2722,7 +2722,7 @@ izip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
it
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
PyErr_Format
(
PyExc_TypeError
,
"
i
zip_longest argument #%zd must support iteration"
,
"zip_longest argument #%zd must support iteration"
,
i
+
1
);
Py_DECREF
(
ittuple
);
return
NULL
;
...
...
@@ -2758,7 +2758,7 @@ izip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static
void
i
zip_longest_dealloc
(
iziplongestobject
*
lz
)
zip_longest_dealloc
(
iziplongestobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_XDECREF
(
lz
->
ittuple
);
...
...
@@ -2768,7 +2768,7 @@ izip_longest_dealloc(iziplongestobject *lz)
}
static
int
i
zip_longest_traverse
(
iziplongestobject
*
lz
,
visitproc
visit
,
void
*
arg
)
zip_longest_traverse
(
iziplongestobject
*
lz
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
lz
->
ittuple
);
Py_VISIT
(
lz
->
result
);
...
...
@@ -2777,7 +2777,7 @@ izip_longest_traverse(iziplongestobject *lz, visitproc visit, void *arg)
}
static
PyObject
*
i
zip_longest_next
(
iziplongestobject
*
lz
)
zip_longest_next
(
iziplongestobject
*
lz
)
{
Py_ssize_t
i
;
Py_ssize_t
tuplesize
=
lz
->
tuplesize
;
...
...
@@ -2848,10 +2848,10 @@ izip_longest_next(iziplongestobject *lz)
return
result
;
}
PyDoc_STRVAR
(
i
zip_longest_doc
,
"
izip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> i
zip_longest object
\n
\
PyDoc_STRVAR
(
zip_longest_doc
,
"
zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) -->
zip_longest object
\n
\
\n
\
Return an
i
zip_longest object whose .__next__() method returns a tuple where
\n
\
Return an zip_longest object whose .__next__() method returns a tuple where
\n
\
the i-th element comes from the i-th iterable argument. The .__next__()
\n
\
method continues until the longest iterable in the argument sequence
\n
\
is exhausted and then it raises StopIteration. When the shorter iterables
\n
\
...
...
@@ -2861,11 +2861,11 @@ defaults to None or can be specified by a keyword argument.\n\
static
PyTypeObject
iziplongest_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"itertools.
i
zip_longest"
,
/* tp_name */
"itertools.zip_longest"
,
/* tp_name */
sizeof
(
iziplongestobject
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
i
zip_longest_dealloc
,
/* tp_dealloc */
(
destructor
)
zip_longest_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
...
...
@@ -2882,13 +2882,13 @@ static PyTypeObject iziplongest_type = {
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
i
zip_longest_doc
,
/* tp_doc */
(
traverseproc
)
i
zip_longest_traverse
,
/* tp_traverse */
zip_longest_doc
,
/* tp_doc */
(
traverseproc
)
zip_longest_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
i
zip_longest_next
,
/* tp_iternext */
(
iternextfunc
)
zip_longest_next
,
/* tp_iternext */
0
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
...
...
@@ -2899,7 +2899,7 @@ static PyTypeObject iziplongest_type = {
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
i
zip_longest_new
,
/* tp_new */
zip_longest_new
,
/* tp_new */
PyObject_GC_Del
,
/* tp_free */
};
...
...
@@ -2915,8 +2915,8 @@ repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\
\n
\
Iterators terminating on the shortest input sequence:
\n
\
izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
\n
\
i
zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
\n
\
i
filterfalse(pred, seq) --> elements of seq where pred(elem) is False
\n
\
zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
\n
\
filterfalse(pred, seq) --> elements of seq where pred(elem) is False
\n
\
islice(seq, [start,] stop [, step]) --> elements from
\n
\
seq[start:stop:step]
\n
\
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...
\n
\
...
...
@@ -2947,7 +2947,7 @@ inititertools(void)
&
islice_type
,
&
starmap_type
,
&
chain_type
,
&
i
filterfalse_type
,
&
filterfalse_type
,
&
count_type
,
&
izip_type
,
&
iziplongest_type
,
...
...
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