Source w/o bytecode: small
(seconds, repeat)
| 60 | |
| 61 | |
| 62 | def 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 | |
| 80 | def _wo_bytecode(module): |