Skip to content

Commit 2a48aa6

Browse files
committed
perf(expr-ir): Optimize ExpansionFlags.from_ir
- Related #2572 (comment) - Child of #2572
1 parent 63c85c8 commit 2a48aa6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

narwhals/_plan/_expansion.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,17 @@ def from_ir(ir: ExprIR, /) -> ExpansionFlags:
130130
has_selector: bool = False
131131
has_exclude: bool = False
132132
for e in ir.iter_left():
133-
if isinstance(e, (Columns, IndexColumns)):
134-
multiple_columns = True
135-
elif isinstance(e, Nth):
136-
has_nth = True
137-
elif isinstance(e, All):
138-
has_wildcard = True
139-
elif isinstance(e, SelectorIR):
140-
has_selector = True
141-
elif isinstance(e, Exclude):
142-
has_exclude = True
133+
if isinstance(e, (_ColumnSelection, SelectorIR)):
134+
if isinstance(e, (Columns, IndexColumns)):
135+
multiple_columns = True
136+
elif isinstance(e, Nth):
137+
has_nth = True
138+
elif isinstance(e, All):
139+
has_wildcard = True
140+
elif isinstance(e, SelectorIR):
141+
has_selector = True
142+
elif isinstance(e, Exclude):
143+
has_exclude = True
143144
return ExpansionFlags(
144145
multiple_columns=multiple_columns,
145146
has_nth=has_nth,

0 commit comments

Comments
 (0)