diff options
author | Barry Warsaw <barry@python.org> | 2023-04-28 23:17:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 23:17:58 (GMT) |
commit | e1f14643dc0e6024f8df9ae975c3b05912a3cb28 (patch) | |
tree | 00bb66f68cadb9457a2a9486873ecf13be0241d6 /Tools/importbench | |
parent | 79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef (diff) | |
download | cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.zip cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.tar.gz cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.tar.bz2 |
gh-98040: Remove just the `imp` module (#98573)
Diffstat (limited to 'Tools/importbench')
-rw-r--r-- | Tools/importbench/importbench.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Tools/importbench/importbench.py b/Tools/importbench/importbench.py index 6c4a537..619263b 100644 --- a/Tools/importbench/importbench.py +++ b/Tools/importbench/importbench.py @@ -6,7 +6,7 @@ thus has no external changes made to import-related attributes in sys. """ from test.test_importlib import util import decimal -import imp +from importlib.util import cache_from_source import importlib import importlib.machinery import json @@ -65,7 +65,7 @@ def source_wo_bytecode(seconds, repeat): name = '__importlib_test_benchmark__' # Clears out sys.modules and puts an entry at the front of sys.path. with util.create_modules(name) as mapping: - assert not os.path.exists(imp.cache_from_source(mapping[name])) + assert not os.path.exists(cache_from_source(mapping[name])) sys.meta_path.append(importlib.machinery.PathFinder) loader = (importlib.machinery.SourceFileLoader, importlib.machinery.SOURCE_SUFFIXES) @@ -80,7 +80,7 @@ def _wo_bytecode(module): name = module.__name__ def benchmark_wo_bytecode(seconds, repeat): """Source w/o bytecode: {}""" - bytecode_path = imp.cache_from_source(module.__file__) + bytecode_path = cache_from_source(module.__file__) if os.path.exists(bytecode_path): os.unlink(bytecode_path) sys.dont_write_bytecode = True @@ -108,9 +108,9 @@ def source_writing_bytecode(seconds, repeat): sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader)) def cleanup(): sys.modules.pop(name) - os.unlink(imp.cache_from_source(mapping[name])) + os.unlink(cache_from_source(mapping[name])) for result in bench(name, cleanup, repeat=repeat, seconds=seconds): - assert not os.path.exists(imp.cache_from_source(mapping[name])) + assert not os.path.exists(cache_from_source(mapping[name])) yield result @@ -121,7 +121,7 @@ def _writing_bytecode(module): assert not sys.dont_write_bytecode def cleanup(): sys.modules.pop(name) - os.unlink(imp.cache_from_source(module.__file__)) + os.unlink(cache_from_source(module.__file__)) yield from bench(name, cleanup, repeat=repeat, seconds=seconds) writing_bytecode_benchmark.__doc__ = ( @@ -141,7 +141,7 @@ def source_using_bytecode(seconds, repeat): importlib.machinery.SOURCE_SUFFIXES) sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader)) py_compile.compile(mapping[name]) - assert os.path.exists(imp.cache_from_source(mapping[name])) + assert os.path.exists(cache_from_source(mapping[name])) yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat, seconds=seconds) |