import_cache: read files only once

This commit is contained in:
Sebastien Bourdeauducq 2021-11-11 20:42:49 +08:00
parent 1ea3cf48d6
commit 95eb218112
1 changed files with 11 additions and 10 deletions

View File

@ -24,6 +24,7 @@ linecache_getlines = None
def add_module_to_cache(module):
if hasattr(module, "__file__"):
fn = module.__file__
if fn not in cache:
try:
with tokenize.open(fn) as fp:
lines = fp.readlines()