MCPcopy Index your code
hub / github.com/python/cpython / _unroll_caches_as_Instructions

Function _unroll_caches_as_Instructions

Lib/test/test_dis.py:2504–2527  ·  view source on GitHub ↗
(instrs, show_caches=False)

Source from the content-addressed store, hash-verified

2502 return output.getvalue()
2503
2504def _unroll_caches_as_Instructions(instrs, show_caches=False):
2505 # Cache entries are no longer reported by dis as fake instructions,
2506 # but some tests assume that do. We should rewrite the tests to assume
2507 # the new API, but it will be clearer to keep the tests working as
2508 # before and do that in a separate PR.
2509
2510 for instr in instrs:
2511 yield instr
2512 if not show_caches:
2513 continue
2514
2515 offset = instr.offset
2516 for name, size, data in (instr.cache_info or ()):
2517 for i in range(size):
2518 offset += 2
2519 # Only show the fancy argrepr for a CACHE instruction when it's
2520 # the first entry for a particular cache value:
2521 if i == 0:
2522 argrepr = f"{name}: {int.from_bytes(data, sys.byteorder)}"
2523 else:
2524 argrepr = ""
2525
2526 yield make_inst("CACHE", 0, None, argrepr, offset, offset,
2527 False, None, None, instr.positions)
2528
2529
2530class TestDisCLI(unittest.TestCase):

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…