mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
gh-112962: in dis module, put cache information in the Instruction instead of creating fake Instructions to represent it (#113016)
This commit is contained in:
parent
3531ea441b
commit
428c9812cb
7 changed files with 115 additions and 47 deletions
|
|
@ -7,6 +7,18 @@ from _testinternalcapi import compiler_codegen, optimize_cfg, assemble_code_obje
|
|||
|
||||
_UNSPECIFIED = object()
|
||||
|
||||
def instructions_with_positions(instrs, co_positions):
|
||||
# Return (instr, positions) pairs from the instrs list and co_positions
|
||||
# iterator. The latter contains items for cache lines and the former
|
||||
# doesn't, so those need to be skipped.
|
||||
|
||||
co_positions = co_positions or iter(())
|
||||
for instr in instrs:
|
||||
yield instr, next(co_positions, ())
|
||||
for _, size, _ in (instr.cache_info or ()):
|
||||
for i in range(size):
|
||||
next(co_positions, ())
|
||||
|
||||
class BytecodeTestCase(unittest.TestCase):
|
||||
"""Custom assertion methods for inspecting bytecode."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue