8000 gh-118761: Improve import time of `cmd` module by donBarbos · Pull Request #130056 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-118761: Improve import time of cmd module #130056

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

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve import time of cmd module
  • Loading branch information
donBarbos committed Feb 12, 2025
commit edf1b9799c2b26d55283c02217a427da18eeeb4e
6 changes: 4 additions & 2 deletions Lib/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
functions respectively.
"""

import inspect, string, sys
import string, sys

__all__ = ["Cmd"]

Expand Down Expand Up @@ -303,9 +303,11 @@ def do_help(self, arg):
try:
func = getattr(self, 'help_' + arg)
except AttributeError:
from inspect import cleandoc

try:
doc=getattr(self, 'do_' + arg).__doc__
doc = inspect.cleandoc(doc)
doc = cleandoc(doc)
if doc:
self.stdout.write("%s\n"%str(doc))
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve import time of :mod:`cmd` by lazy importing :mod:`inspect`. Patch by
Semyon Moroz.
Loading
0