Skip to content

Commit 8da4627

Browse files
committed
use iterators rather than indexing
1 parent d4368ba commit 8da4627

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pandas/indexes/multi.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,16 +2336,13 @@ def _check_equal_length(seq_of_seqs):
23362336
Ensure that all sequences in seq_of_seqs are the same length.
23372337
23382338
Since this function is time critical, it does zero error checking.
2339-
Two exceptions can result from calling this function.
2340-
1. IndexError: seq_of_seqs is not an indexed sequence.
2341-
2. TypeError: An inner sequence does not support len().
2342-
2343-
This check is up to O(n) and can be expensive, so use only when necessary.
2339+
A TypeError will be raised if inner sequence does not support len().
23442340
23452341
Return True if all sequences are the same length, otherwise False
23462342
"""
2347-
L0 = len(seq_of_seqs[0])
2348-
for seq in seq_of_seqs:
2343+
seq_it = iter(seq_of_seqs)
2344+
L0 = len(next(seq_it))
2345+
for seq in seq_it:
23492346
if len(seq) != L0:
23502347
return False
23512348
return True

0 commit comments

Comments
 (0)