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

Function source_writing_bytecode

Tools/importbench/importbench.py:101–115  ·  view source on GitHub ↗

Source writing bytecode: small

(seconds, repeat)

Source from the content-addressed store, hash-verified

99
100
101def source_writing_bytecode(seconds, repeat):
102 """Source writing bytecode: small"""
103 assert not sys.dont_write_bytecode
104 name = '__importlib_test_benchmark__'
105 with util.create_modules(name) as mapping:
106 sys.meta_path.append(importlib.machinery.PathFinder)
107 loader = (importlib.machinery.SourceFileLoader,
108 importlib.machinery.SOURCE_SUFFIXES)
109 sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
110 def cleanup():
111 sys.modules.pop(name)
112 os.unlink(cache_from_source(mapping[name]))
113 for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
114 assert not os.path.exists(cache_from_source(mapping[name]))
115 yield result
116
117
118def _writing_bytecode(module):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…