Skip to content

Commit d58ddd2

Browse files
committed
Remove Instruction::MapAddRev
1 parent 8685c4f commit d58ddd2

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

bytecode/src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,6 @@ pub enum Instruction {
393393
GetAIter,
394394
GetANext,
395395
EndAsyncFor,
396-
397-
/// Reverse order evaluation in MapAdd
398-
/// required to support named expressions of Python 3.8 in dict comprehension
399-
/// today (including Py3.9) only required in dict comprehension.
400-
MapAddRev {
401-
i: u32,
402-
},
403396
}
404397

405398
use self::Instruction::*;
@@ -1024,7 +1017,7 @@ impl Instruction {
10241017
}
10251018
BuildSlice { step } => -2 - (*step as i32) + 1,
10261019
ListAppend { .. } | SetAdd { .. } => -1,
1027-
MapAdd { .. } | MapAddRev { .. } => -2,
1020+
MapAdd { .. } => -2,
10281021
PrintExpr => -1,
10291022
LoadBuildClass => 1,
10301023
UnpackSequence { size } => -1 + *size as i32,
@@ -1187,7 +1180,7 @@ impl Instruction {
11871180
BuildSlice { step } => w!(BuildSlice, step),
11881181
ListAppend { i } => w!(ListAppend, i),
11891182
SetAdd { i } => w!(SetAdd, i),
1190-
MapAddRev { i } => w!(MapAddRev, i),
1183+
MapAdd { i } => w!(MapAdd, i),
11911184
PrintExpr => w!(PrintExpr),
11921185
LoadBuildClass => w!(LoadBuildClass),
11931186
UnpackSequence { size } => w!(UnpackSequence, size),
@@ -1199,7 +1192,6 @@ impl Instruction {
11991192
GetAIter => w!(GetAIter),
12001193
GetANext => w!(GetANext),
12011194
EndAsyncFor => w!(EndAsyncFor),
1202-
MapAdd { i } => w!(MapAdd, i),
12031195
}
12041196
}
12051197
}

compiler/src/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ impl Compiler {
21362136
compiler.compile_expression(key)?;
21372137
compiler.compile_expression(value)?;
21382138

2139-
compiler.emit(Instruction::MapAddRev {
2139+
compiler.emit(Instruction::MapAdd {
21402140
i: generators.len() as u32,
21412141
});
21422142

vm/src/frame.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,6 @@ impl ExecutingFrame<'_> {
688688
Ok(None)
689689
}
690690
bytecode::Instruction::MapAdd { i } => {
691-
let key = self.pop_value();
692-
let value = self.pop_value();
693-
let obj = self.nth_value(*i);
694-
let dict: &Py<PyDict> = unsafe {
695-
// SAFETY: trust compiler
696-
obj.downcast_unchecked_ref()
697-
};
698-
dict.set_item(&*key, value, vm)?;
699-
Ok(None)
700-
}
701-
bytecode::Instruction::MapAddRev { i } => {
702-
// change order of evalutio of key and value to support Py3.8 Named expressions in dict comprehension
703691
let value = self.pop_value();
704692
let key = self.pop_value();
705693
let obj = self.nth_value(*i);

0 commit comments

Comments
 (0)