From 3a6a58bf5fce29eb0e2a580c21e3f87023007c5f Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 3 Apr 2024 12:16:52 +0100 Subject: [PATCH] gh-67224: Make linecache imports relative to improve startup speed --- Lib/linecache.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/linecache.py b/Lib/linecache.py index b97999fc1dc909c..0fcd91cfb589324 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -5,9 +5,6 @@ that name. """ -import sys -import os - __all__ = ["getline", "clearcache", "checkcache", "lazycache"] @@ -48,6 +45,7 @@ def getlines(filename, module_globals=None): def checkcache(filename=None): + import os """Discard cache entries that are out of date. (This is not checked upon each call!)""" @@ -76,6 +74,9 @@ def checkcache(filename=None): def updatecache(filename, module_globals=None): + import os + import sys + """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list."""