New submission from Pankaj Pandey <panka...@gmail.com>: The specific os.path.exists() call is shown here: https://github.com/python/cpython/pull/6805
If the filename is already in linecache or the module has a PEP 302 loader, then the os.path.exists() call is ignored. Hence it is better to call it only if its value is needed. Attached a very simple case which shows the impact of the change: ---------- files: inspect_stack_perf.py messages: 317186 nosy: Pankaj Pandey priority: normal pull_requests: 6667 severity: normal status: open title: inspect.getsource performs unnecessary filesystem stat call which is ignored in some circumstances Added file: https://bugs.python.org/file47607/inspect_stack_perf.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33587> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com