[issue33587] inspect.getsource performs unnecessary filesystem stat call

2018-06-12 Thread Pankaj Pandey
Pankaj Pandey added the comment: I simply profiled the script with "python -m cProfile -s cumtime inspect_stack_perf.py" And yes, I should move the linecache check first, that would be a better idea. Though getmodule() is also fast enough and reordering it does not significant

[issue33587] inspect.getsource performs unnecessary filesystem stat call which is ignored in some circumstances

2018-05-20 Thread Pankaj Pandey
Pankaj Pandey <panka...@gmail.com> added the comment: Here's the patch performance difference before and after the patch: Before: Sun May 20 21:42:32 2018prof1.stat 1188991 function calls (1188851 primitive calls) in 4.821 seconds Ordered by: cumulative time

[issue33587] inspect.getsource performs unnecessary filesystem stat call which is ignored in some circumstances

2018-05-20 Thread Pankaj Pandey
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