Title: Speed up import rlcompleter by deferring inspect and re · Issue #156363 · python/cpython · GitHub
Open Graph Title: Speed up import rlcompleter by deferring inspect and re · Issue #156363 · python/cpython
X Title: Speed up import rlcompleter by deferring inspect and re · Issue #156363 · python/cpython
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 in Completer._callable_postfix re: only in Completer...
Open Graph 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 in Completer...
X 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 in Completer...
Opengraph URL: https://github.com/python/cpython/issues/156363
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Speed up import rlcompleter by deferring inspect and re","articleBody":"`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:\n\n- `inspect`: only in `Completer._callable_postfix`\n- `re`: only in `Completer.attr_matches`\n\n`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.\n\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156364\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maxday","@type":"Person","name":"maxday"},"datePublished":"2026-08-25T12:57:27Z","url":"https://github.com/python/cpython/issues/156363"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:aadd3b5f-6fee-b6cf-5beb-f753d514ecbf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A00:19E4BB:39DD3EC:49CC69D:6B02017A |
| html-safe-nonce | 68000691c8b670f235496adaa147ad637ea33c4ca7a750795e45503ede90fa2d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTAwOjE5RTRCQjozOUREM0VDOjQ5Q0M2OUQ6NkIwMjAxN0EiLCJ2aXNpdG9yX2lkIjoiNjMxMTIyOTQ5ODY1MDEzMjg1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bfffaeb8a886a41022c1c5b77ff7d101a8dae8b48805ce1f49d0fd047abafc51 |
| hovercard-subject-tag | issue:5246098033 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156363/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a817fae01922c0d73814ecb0d3897ddb9c973227dcc9682d37008b0ac6af03d/python/cpython/issues/156363 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a817fae01922c0d73814ecb0d3897ddb9c973227dcc9682d37008b0ac6af03d/python/cpython/issues/156363 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maxday |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width