-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
GH-130328: Speedup pasting in legacy console on Windows #133728
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
Conversation
for i in range(rec_count): | ||
rec = recs[i] | ||
# In case of a legacy console, we do not only receive a keydown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there is a lot of duplicated logic from get_event
now. Maybe refactor that, so the logic can be reused here?
@@ -449,8 +442,11 @@ def get_event(self, block: bool = True) -> Event | None: | ||
and there is no event pending, otherwise waits for the | ||
completion of an event.""" | ||
|
||
if not block and not self.wait(timeout=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved blocking and waiting logic into get_event
like in unix_console.py
. IMHO that shouldn't be part of reading and we're in perfect sync with Unix now.
@@ -484,7 +491,6 @@ def do(self) -> None: | ||
data = "" | ||
start = time.time() | ||
while done not in data: | ||
self.reader.console.wait(100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. Works for me without it. For both, Linux and Windows, this will immediately return in case of pending data, and just needlessly waits 100 ms if there is no more data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect. You utilized my getpending()
implementation without adding any double-buffering. It is indeed speeding things up dramatically while not breaking the existing bracketed paste behavior.
Thanks @chris-eibl for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…gh-133728) (cherry picked from commit 91b4886) Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
GH-134653 is a backport of this pull request to the 3.14 branch. |
|
@chris-eibl this buildbot failure ^^^ is real. I can't explain that yet and cannot reproduce it locally on Win 11, but if I don't manage to fix it before tomorrow's 3.14 beta 2, I will have to revert the backport. |
|
I can reproduce these failures on Windows 10, too, for both main and 3.14 when running in a legacy console. In fact, the fix is simple:
in these tests I've introduced in #132439. They shouldn't depend on I must have run the tests back then in a Windows terminal, and most probably all the GH bots are Windows 11 based, too? |
Do you want me to create a PR or is the above diff sufficient? |
pythongh-134660) (cherry picked from commit 1000283) Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.