Skip to content

Commit f03c031

Browse files
committed
fixed partitions to not copy the sequence.
1 parent 4022c36 commit f03c031

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python_toolbox/sequence_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ def partitions(sequence, partition_size=None, n_partitions=None,
135135

136136
enlarged_length = partition_size * n_partitions
137137

138+
filler = []
138139
if fillvalue != NoFillValue:
139140
filler = itertools.repeat(fillvalue, enlarged_length - sequence_length)
140-
sequence = list(itertools.chain(sequence, filler))
141141

142142
blocks = [sequence[i : i + partition_size] for i in
143143
xrange(0, enlarged_length, partition_size)]
144+
blocks[-1].extend(filler)
144145

145146
return blocks
146147

0 commit comments

Comments
 (0)