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

Function source_wo_bytecode

Tools/importbench/importbench.py:62–77  ·  view source on GitHub ↗

Source w/o bytecode: small

(seconds, repeat)

Source from the content-addressed store, hash-verified

60
61
62def source_wo_bytecode(seconds, repeat):
63 """Source w/o bytecode: small"""
64 sys.dont_write_bytecode = True
65 try:
66 name = '__importlib_test_benchmark__'
67 # Clears out sys.modules and puts an entry at the front of sys.path.
68 with util.create_modules(name) as mapping:
69 assert not os.path.exists(cache_from_source(mapping[name]))
70 sys.meta_path.append(importlib.machinery.PathFinder)
71 loader = (importlib.machinery.SourceFileLoader,
72 importlib.machinery.SOURCE_SUFFIXES)
73 sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
74 yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
75 seconds=seconds)
76 finally:
77 sys.dont_write_bytecode = False
78
79
80def _wo_bytecode(module):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…