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

Function source_using_bytecode

Tools/importbench/importbench.py:136–147  ·  view source on GitHub ↗

Source w/ bytecode: small

(seconds, repeat)

Source from the content-addressed store, hash-verified

134
135
136def source_using_bytecode(seconds, repeat):
137 """Source w/ bytecode: small"""
138 name = '__importlib_test_benchmark__'
139 with util.create_modules(name) as mapping:
140 sys.meta_path.append(importlib.machinery.PathFinder)
141 loader = (importlib.machinery.SourceFileLoader,
142 importlib.machinery.SOURCE_SUFFIXES)
143 sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
144 py_compile.compile(mapping[name])
145 assert os.path.exists(cache_from_source(mapping[name]))
146 yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
147 seconds=seconds)
148
149
150def _using_bytecode(module):

Callers

nothing calls this directly

Calls 7

cache_from_sourceFunction · 0.85
benchFunction · 0.85
appendMethod · 0.45
path_hookMethod · 0.45
compileMethod · 0.45
existsMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…