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

Method get_load_const

Lib/test/test_ast/test_ast.py:2643–2651  ·  view source on GitHub ↗
(self, tree)

Source from the content-addressed store, hash-verified

2641 self.assertEqual(ast.get_docstring(tree), 'docstring')
2642
2643 def get_load_const(self, tree):
2644 # Compile to bytecode, disassemble and get parameter of LOAD_CONST
2645 # instructions
2646 co = compile(tree, '<string>', 'exec')
2647 consts = []
2648 for instr in dis.get_instructions(co):
2649 if instr.opcode in dis.hasconst:
2650 consts.append(instr.argval)
2651 return consts
2652
2653 @support.cpython_only
2654 def test_load_const(self):

Callers 1

test_load_constMethod · 0.95

Calls 3

get_instructionsMethod · 0.80
compileFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected