mirror of https://github.com/python/cpython
Fix typo and add a module prefix (GH-28401)
This commit is contained in:
parent
fdc6b3d931
commit
80d9ff1648
|
@ -821,14 +821,14 @@ which incur interpreter overhead.
|
|||
|
||||
def triplewise(iterable):
|
||||
"Return overlapping triplets from an iterable"
|
||||
# pairwise('ABCDEFG') -> ABC BCD CDE DEF EFG
|
||||
# triplewise('ABCDEFG') -> ABC BCD CDE DEF EFG
|
||||
for (a, _), (b, c) in pairwise(pairwise(iterable)):
|
||||
yield a, b, c
|
||||
|
||||
def sliding_window(iterable, n):
|
||||
# sliding_window('ABCDEFG', 4) -> ABCD BCDE CDEF DEFG
|
||||
it = iter(iterable)
|
||||
window = deque(islice(it, n), maxlen=n)
|
||||
window = collections.deque(islice(it, n), maxlen=n)
|
||||
if len(window) == n:
|
||||
yield tuple(window)
|
||||
for x in it:
|
||||
|
|
Loading…
Reference in New Issue