Skip to content

Commit ab7d46c

Browse files
Merge branch 'main' into cythonize
2 parents 386fb8c + 40b6bd4 commit ab7d46c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/bytecode/concrete.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)