]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-33587: inspect.getsource: reorder stat on file in linecache (GH-6805)
authorPankaj Pandey <pankaj86@gmail.com>
Fri, 26 Aug 2022 14:20:48 +0000 (10:20 -0400)
committerGitHub <noreply@github.com>
Fri, 26 Aug 2022 14:20:48 +0000 (15:20 +0100)
commitc1581a928cc153076593c5c433a8dd36ce10fbfb
tree0dba5a9e164afda6a4976f76d4322bc29fdf90ab
parent771eff21a0984327a95013e2bd1d57b1f1a0e89d
bpo-33587: inspect.getsource: reorder stat on file in linecache (GH-6805)

* inspect.getsource: avoid stat on file in linecache

The check for os.path.exists() on source file is postponed in
inspect.getsourcefile() until needed avoiding an expensive filesystem
stat call and PEP 302 module loader check is moved last for performance
since it is an uncommon case.
Lib/inspect.py