Skip to content

Commit a33b578

Browse files
committed
Avoid using .index()
1 parent e052d81 commit a33b578

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

toolz/itertoolz.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,12 @@ def partition_all(n, seq):
720720
yield prev
721721
prev = item
722722
if prev[-1] is no_pad:
723-
yield prev[:prev.index(no_pad)]
723+
# Get first index of no_pad without using .index()
724+
# https://github.com/pytoolz/toolz/issues/387
725+
for ind, item in enumerate(reversed(prev)):
726+
if item is not no_pad:
727+
yield prev[:len(prev)-ind]
728+
break
724729
else:
725730
yield prev
726731

0 commit comments

Comments
 (0)