rlcompleter imports inspect and re at module scope, but neither is needed to import the module or to construct a Completer. Each is used in exactly one completion method:
inspect: only in Completer._callable_postfix
re: only in Completer.attr_matches
inspect in particular is a heavy import: it transitively pulls in dis, tokenize, and more. Because rlcompleter is imported during interactive startup (to set up tab completion via readline), this import cost is paid on every interactive session and every import rlcompleter, even though the completion methods may never run.
Linked PRs
rlcompleterimportsinspectandreat module scope, but neither is needed to import the module or to construct aCompleter. Each is used in exactly one completion method:inspect: only inCompleter._callable_postfixre: only inCompleter.attr_matchesinspectin particular is a heavy import: it transitively pulls indis,tokenize, and more. Becauserlcompleteris imported during interactive startup (to set up tab completion viareadline), this import cost is paid on every interactive session and everyimport rlcompleter, even though the completion methods may never run.Linked PRs