Skip to content

Commit 24e2362

Browse files
committed
allow also range as a sequence (indexable) in llist.llist
1 parent b59b3cc commit 24e2362

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

unpythonic/llist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,16 @@ def llist(iterable):
277277
reversed list that is internally stored by the iterator.
278278
279279
- Sequences, since they can be walked backwards; a linear walk is enough.
280-
Here a sequence is defined as tuple, list, or any custom class inheriting
281-
from ``collections.abc.Sequence``.
280+
Here a sequence is defined as tuple, list, range, or any custom class
281+
inheriting from ``collections.abc.Sequence``.
282282
283283
For a general iterable input, this costs a linear walk (forwards), plus an
284284
``lreverse`` once the list has been fully consed.
285285
"""
286286
if isinstance(iterable, ReversedLinkedListIterator):
287287
# avoid two extra reverses by reusing the internal data.
288288
return iterable._data
289-
if isinstance(iterable, (tuple, list, Sequence)):
289+
if isinstance(iterable, (tuple, list, range, Sequence)):
290290
return foldr(cons, nil, iterable) # sequences can be walked backwards
291291
# general iterable requires walking forwards, then reversing the result
292292
# because cons appends to the front.

0 commit comments

Comments
 (0)