Skip to content

Commit a3be1ca

Browse files
committed
Limit the scope of optimization.
1 parent 4a82746 commit a3be1ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

more_itertools/recipes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import warnings
1212

1313
from collections import deque
14-
from collections.abc import Sized
14+
from collections.abc import Collection
1515
from itertools import (
1616
chain,
1717
combinations,
@@ -107,7 +107,7 @@ def tail(n, iterable):
107107
['E', 'F', 'G']
108108
109109
"""
110-
if isinstance(iterable, Sized):
110+
if isinstance(iterable, Collection):
111111
yield from islice(iterable, max(0, len(iterable) - n), None)
112112
else:
113113
yield from iter(deque(iterable, maxlen=n))

0 commit comments

Comments
 (0)