Cache return values to avoid repeated function calls.

This commit is contained in:
garenchan 2018-10-23 22:10:20 +08:00
parent 0b7a74dda3
commit 9bc87d09c6

View file

@ -206,8 +206,9 @@ def prepare_import(path):
"""
path = os.path.realpath(path)
if os.path.splitext(path)[1] == '.py':
path = os.path.splitext(path)[0]
fname, ext = os.path.splitext(path)
if ext == '.py':
path = fname
if os.path.basename(path) == '__init__':
path = os.path.dirname(path)