New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inspect.getsource performs unnecessary filesystem stat call #77768
Comments
Here's the patch performance difference before and after the patch: Before: Sun May 20 21:42:32 2018 prof1.stat
Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) After the patch: Sun May 20 21:39:44 2018 prof2.stat
Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) Total runtime reduced from 4.8 s to 2.8 s, and the major difference can be seen in the |
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 to profile this and the command line by which it was invoked? |
I simply profiled the script with "python -m cProfile -s cumtime inspect_stack_perf.py" |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: