Skip to content

Commit f8b62dc

Browse files
committed
Remove the unnecessary SWAP(2)
1 parent 85ac67a commit f8b62dc

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Lib/test/test_compile.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,9 +2371,6 @@ def test_attribute_del(self):
23712371
self.assertOpcodeSourcePositionIs(
23722372
code, "PUSH_NULL", line=4, end_line=4, column=5, end_column=8
23732373
)
2374-
self.assertOpcodeSourcePositionIs(
2375-
code, "SWAP", line=4, end_line=4, column=5, end_column=8
2376-
)
23772374
self.assertOpcodeSourcePositionIs(
23782375
code, "STORE_ATTR", line=4, end_line=4, column=5, end_column=8
23792376
)

Python/codegen.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5449,19 +5449,20 @@ codegen_visit_expr(compiler *c, expr_ty e)
54495449
}
54505450
}
54515451
RETURN_IF_ERROR(_PyCompile_MaybeAddStaticAttributeToClass(c, e));
5452-
VISIT(c, expr, e->v.Attribute.value);
54535452
loc = LOC(e);
54545453
loc = update_start_location_to_match_attr(c, loc, e);
54555454
switch (e->v.Attribute.ctx) {
54565455
case Load:
5456+
VISIT(c, expr, e->v.Attribute.value);
54575457
ADDOP_NAME(c, loc, LOAD_ATTR, e->v.Attribute.attr, names);
54585458
break;
54595459
case Store:
5460+
VISIT(c, expr, e->v.Attribute.value);
54605461
ADDOP_NAME(c, loc, STORE_ATTR, e->v.Attribute.attr, names);
54615462
break;
54625463
case Del:
54635464
ADDOP(c, loc, PUSH_NULL);
5464-
ADDOP_I(c, loc, SWAP, 2);
5465+
VISIT(c, expr, e->v.Attribute.value);
54655466
ADDOP_NAME(c, loc, STORE_ATTR, e->v.Attribute.attr, names);
54665467
break;
54675468
}

0 commit comments

Comments
 (0)