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

Function _get_code_array

Lib/dis.py:219–240  ·  view source on GitHub ↗
(co, adaptive)

Source from the content-addressed store, hash-verified

217 return _all_opmap[deoptmap[name]] if name in deoptmap else op
218
219def _get_code_array(co, adaptive):
220 if adaptive:
221 code = co._co_code_adaptive
222 res = []
223 found = False
224 for i in range(0, len(code), 2):
225 op, arg = code[i], code[i+1]
226 if op == ENTER_EXECUTOR:
227 try:
228 ex = get_executor(co, i)
229 except (ValueError, RuntimeError):
230 ex = None
231
232 if ex:
233 op, arg = ex.get_opcode(), ex.get_oparg()
234 found = True
235
236 res.append(op.to_bytes())
237 res.append(arg.to_bytes())
238 return code if not found else b''.join(res)
239 else:
240 return co.co_code
241
242def code_info(x):
243 """Formatted details of methods, functions, or code."""

Callers 4

get_instructionsFunction · 0.85
disassembleFunction · 0.85
__iter__Method · 0.85
disMethod · 0.85

Calls 2

appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…