[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 significantly change the

[issue33587] inspect.getsource performs unnecessary filesystem stat call

2018-06-10 Thread Tal Einat
Tal Einat added the comment: Moving the linecache check up before the two others seems like a simple and safe optimization. On the other hand, I'm not sure calling getmodule() before checking if the file exists would be faster in many cases. Pankaj, could you also include the script you ran

[issue33587] inspect.getsource performs unnecessary filesystem stat call

2018-05-25 Thread Terry J. Reedy
Change by Terry J. Reedy : -- stage: -> patch review type: -> performance versions: +Python 3.8 ___ Python tracker ___

[issue33587] inspect.getsource performs unnecessary filesystem stat call

2018-05-25 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: +yselivanov title: inspect.getsource performs unnecessary filesystem stat call which is ignored in some circumstances -> inspect.getsource performs unnecessary filesystem stat call ___ Python

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

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

[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 : 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