Speed up import rlcompleter by deferring inspect and re
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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 inCompleter._callable_postfixre: only inCompleter.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
- gh-156364
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rlcompleter module and the Completer._callable_postfix and Completer.attr_matches entry points named in the issue. Verify the import behavior before and after the change, and confirm that completion behavior remains correct while importing rlcompleter no longer pays for unused dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, developer-experience
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100