Slightly optimize transpose_sequence
@@ -13,8 +13,11 @@ def _transpose(xs, length):
lengths = numpy.empty(length, dtype='i')
end = length
for i, x in enumerate(xs):
- lengths[len(x):end] = i
- end = len(x)
+ l = len(x)
+ if l == end:
+ continue
+ lengths[l:end] = i
+ end = l
lengths[0:end] = len(xs)
if xp is numpy:
