Skip to content

Commit 6593c26

Browse files
committed
use iterators rather than indexing
1 parent 0c2ca79 commit 6593c26

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
@@ -2376,16 +2376,13 @@ def _check_equal_length(seq_of_seqs):
23762376
Ensure that all sequences in seq_of_seqs are the same length.
23772377
23782378
Since this function is time critical, it does zero error checking.
2379-
Two exceptions can result from calling this function.
2380-
1. IndexError: seq_of_seqs is not an indexed sequence.
2381-
2. TypeError: An inner sequence does not support len().
2382-
2383-
This check is up to O(n) and can be expensive, so use only when necessary.
2379+
A TypeError will be raised if inner sequence does not support len().
23842380
23852381
Return True if all sequences are the same length, otherwise False
23862382
"""
2387-
L0 = len(seq_of_seqs[0])
2388-
for seq in seq_of_seqs:
2383+
seq_it = iter(seq_of_seqs)
2384+
L0 = len(next(seq_it))
2385+
for seq in seq_it:
23892386
if len(seq) != L0:
23902387
return False
23912388
return True

0 commit comments

Comments
 (0)