Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-118761: Optimise import time forshlex#132036

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AA-Turner merged 6 commits intopython:mainfromAA-Turner:opt-shlex
Apr 24, 2025
Merged
Changes from1 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
PrevPrevious commit
NextNext commit
Revert deferral of sys and io
  • Loading branch information
@AA-Turner
AA-Turner committedApr 4, 2025
commit8811463aed98455641958e4a64cf7ba242ac283e
7 changes: 3 additions & 4 deletionsLib/shlex.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,9 @@
# iterator interface by Gustavo Niemeyer, April 2003.
# changes to tokenize more like Posix shells by Vinay Sajip, July 2016.

import sys
from io import StringIO

__all__ = ["shlex", "split", "quote", "join"]

class shlex:
Expand All@@ -16,13 +19,11 @@ def __init__(self, instream=None, infile=None, posix=False,
from collections import deque # deferred import for performance

if isinstance(instream, str):
from io import StringIO # deferred import for performance
instream = StringIO(instream)
if instream is not None:
self.instream = instream
self.infile = infile
else:
import sys # deferred import for performance
self.instream = sys.stdin
self.infile = None
self.posix = posix
Expand DownExpand Up@@ -75,7 +76,6 @@ def push_token(self, tok):
def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack."
if isinstance(newstream, str):
from io import StringIO # deferred import for performance
newstream = StringIO(newstream)
self.filestack.appendleft((self.infile, self.instream, self.lineno))
self.infile = newfile
Expand DownExpand Up@@ -343,7 +343,6 @@ def _print_tokens(lexer):
print("Token: " + repr(tt))

if __name__ == '__main__':
import sys # deferred import for performance
if len(sys.argv) == 1:
_print_tokens(shlex())
else:
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp