Skip to content

Commit 736c0ab

Browse files
committed
Move itertools izip() code to builtins as zip(). Complete the renaming.
1 parent c5a2eb9 commit 736c0ab

11 files changed

Lines changed: 281 additions & 476 deletions

File tree

Include/iterobject.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ extern "C" {
77

88
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
99
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
10-
PyAPI_DATA(PyTypeObject) PyZipIter_Type;
1110
PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type;
1211

1312
#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type)
@@ -19,8 +18,6 @@ PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
1918

2019
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
2120

22-
PyObject* _PyZip_CreateIter(PyObject* args);
23-
2421
#ifdef __cplusplus
2522
}
2623
#endif

Lib/filecmp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
import stat
1414
import warnings
15-
from itertools import filterfalse, izip
15+
from itertools import filterfalse
1616

1717
__all__ = ["cmp","dircmp","cmpfiles"]
1818

@@ -130,8 +130,8 @@ def phase0(self): # Compare everything except common subdirectories
130130
self.right_list.sort()
131131

132132
def phase1(self): # Compute common names
133-
a = dict(izip(map(os.path.normcase, self.left_list), self.left_list))
134-
b = dict(izip(map(os.path.normcase, self.right_list), self.right_list))
133+
a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))
134+
b = dict(zip(map(os.path.normcase, self.right_list), self.right_list))
135135
self.common = list(map(a.__getitem__, filter(b.__contains__, a)))
136136
self.left_only = list(map(a.__getitem__, filterfalse(b.__contains__, a)))
137137
self.right_only = list(map(b.__getitem__, filterfalse(a.__contains__, b)))

Lib/heapq.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
130130
'nlargest', 'nsmallest']
131131

132-
from itertools import islice, repeat, count, izip, tee
132+
from itertools import islice, repeat, count, tee
133133
from operator import itemgetter, neg
134134
import bisect
135135

@@ -352,7 +352,7 @@ def nsmallest(n, iterable, key=None):
352352
"""
353353
in1, in2 = tee(iterable)
354354
keys = in1 if key is None else map(key, in1)
355-
it = izip(keys, count(), in2) # decorate
355+
it = zip(keys, count(), in2) # decorate
356356
result = _nsmallest(n, it)
357357
return list(map(itemgetter(2), result)) # undecorate
358358

@@ -364,7 +364,7 @@ def nlargest(n, iterable, key=None):
364364
"""
365365
in1, in2 = tee(iterable)
366366
keys = in1 if key is None else map(key, in1)
367-
it = izip(keys, map(neg, count()), in2) # decorate
367+
it = zip(keys, map(neg, count()), in2) # decorate
368368
result = _nlargest(n, it)
369369
return list(map(itemgetter(2), result)) # undecorate
370370

Lib/test/seq_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __iter__(self):
7979
def __next__(self):
8080
raise StopIteration
8181

82-
from itertools import chain, map
82+
from itertools import chain
8383
def itermulti(seqn):
8484
'Test multiple tiers of iterators'
8585
return chain(map(lambda x:x, iterfunc(IterGen(Sequence(seqn)))))

Lib/test/test_ast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys, itertools
1+
import sys
22
import _ast
33

44
def to_tuple(t):
@@ -142,7 +142,7 @@ def run_tests():
142142
for input, output, kind in ((exec_tests, exec_results, "exec"),
143143
(single_tests, single_results, "single"),
144144
(eval_tests, eval_results, "eval")):
145-
for i, o in itertools.izip(input, output):
145+
for i, o in zip(input, output):
146146
ast_tree = compile(i, "?", kind, 0x400)
147147
tup = to_tuple(ast_tree)
148148
assert tup == o, ("kind=%r\ninput=%r\nexpected=%r\ngot=%r" %

Lib/test/test_heapq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def __iter__(self):
260260
def __next__(self):
261261
raise StopIteration
262262

263-
from itertools import chain, map
263+
from itertools import chain
264264
def L(seqn):
265265
'Test multiple tiers of iterators'
266266
return chain(map(lambda x:x, R(Ig(G(seqn)))))

0 commit comments

Comments
 (0)