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