Cache return values to avoid repeated function calls.

This commit is contained in:
garenchan 2018-10-23 22:10:20 +08:00
parent 05644138fc
commit 7a334062ef

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)