File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,13 +390,20 @@ def from_code(
390390 pos_iter : Iterator [
391391 Tuple [Optional [int ], Optional [int ], Optional [int ], Optional [int ]]
392392 ] = iter (code .co_positions ())
393+ _last_pos : Optional [
394+ Tuple [Optional [int ], Optional [int ], Optional [int ], Optional [int ]]
395+ ] = None
396+ _last_loc : Optional [InstrLocation ] = None
393397 for offset in range (0 , len (bc ), 2 ):
394398 op = bc [offset ]
395399 arg = bc [offset + 1 ] if opcode_has_argument (op ) else UNSET
396400 pos = next (pos_iter , None )
397- loc : Optional [InstrLocation ] = (
398- InstrLocation ._from_tuple (* pos ) if pos is not None else None
399- )
401+ if pos == _last_pos :
402+ loc : Optional [InstrLocation ] = _last_loc
403+ else :
404+ loc = InstrLocation ._from_tuple (* pos ) if pos is not None else None
405+ _last_pos = pos
406+ _last_loc = loc
400407 instructions .append (ConcreteInstr ._from_opcode (opname [op ], op , arg , loc ))
401408
402409 bytecode = ConcreteBytecode ()
You can’t perform that action at this time.
0 commit comments