-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-67224: Make linecache imports relative to improve startup speed #117501
Conversation
pablogsal
commented
Apr 3, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: python -c: Line causing exception not shown for exceptions other than SyntaxErrors #67224
Oh man, seems this is complicated because making the import lazy actually fails at shutdown because if the first time this is called its when the interpreter is shutting down, sys.meta_path is None :( |
Well, I think this should do the trick |
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a suggestion to reorganize checkcache() import/except ImportError.
pythongh-117501 put some code before the docstring, so now it is no longer recognized as a docstring.
# and slow down the startup sequence. | ||
import os | ||
import sys | ||
|
||
"""Update a cache entry and return its list of lines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We lost the docstring because you put the imports before it. Filed #117948 to fix this.
gh-117501 put some code before the docstring, so now it is no longer recognized as a docstring.
pythongh-117501 put some code before the docstring, so now it is no longer recognized as a docstring.