Move itertools izip() code to builtins as zip(). Complete the renaming.

This commit is contained in:
Raymond Hettinger 2008-03-13 02:09:15 +00:00
parent c5a2eb949c
commit 736c0ab428
11 changed files with 281 additions and 476 deletions

View file

@ -129,7 +129,7 @@ From all times, sorting has always been a Great Art! :-)
__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
'nlargest', 'nsmallest']
from itertools import islice, repeat, count, izip, tee
from itertools import islice, repeat, count, tee
from operator import itemgetter, neg
import bisect
@ -352,7 +352,7 @@ def nsmallest(n, iterable, key=None):
"""
in1, in2 = tee(iterable)
keys = in1 if key is None else map(key, in1)
it = izip(keys, count(), in2) # decorate
it = zip(keys, count(), in2) # decorate
result = _nsmallest(n, it)
return list(map(itemgetter(2), result)) # undecorate
@ -364,7 +364,7 @@ def nlargest(n, iterable, key=None):
"""
in1, in2 = tee(iterable)
keys = in1 if key is None else map(key, in1)
it = izip(keys, map(neg, count()), in2) # decorate
it = zip(keys, map(neg, count()), in2) # decorate
result = _nlargest(n, it)
return list(map(itemgetter(2), result)) # undecorate