MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_code_array

Function _get_code_array

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

Source from the content-addressed store, hash-verified

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

Callers 4

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

Calls 5

get_executorFunction · 0.90
lenFunction · 0.85
to_bytesMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected