File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,6 +181,24 @@ def assemble(self) -> bytes:
181181
182182 return bytes (b )
183183
184+ @classmethod
185+ def _from_opcode (
186+ cls : Type [T ],
187+ name : str ,
188+ opcode : int ,
189+ arg : int ,
190+ location : Optional [InstrLocation ],
191+ ) -> T :
192+ """Fast path for from_code: arg is a raw byte (0-255), size is always 2."""
193+ new = object .__new__ (cls )
194+ new ._name = name
195+ new ._opcode = opcode
196+ new ._arg = arg
197+ new ._location = location
198+ new ._extended_args = None
199+ new ._size = 2
200+ return new
201+
184202 @classmethod
185203 def disassemble (cls : Type [T ], lineno : Optional [int ], code : bytes , offset : int ) -> T :
186204 index = 2 * offset
@@ -353,7 +371,7 @@ def from_code(
353371 loc : Optional [InstrLocation ] = (
354372 InstrLocation ._from_tuple (* pos ) if pos is not None else None
355373 )
356- instructions .append (ConcreteInstr (opname [op ], arg , location = loc ))
374+ instructions .append (ConcreteInstr . _from_opcode (opname [op ], op , arg , loc ))
357375
358376 bytecode = ConcreteBytecode ()
359377
You can’t perform that action at this time.
0 commit comments