GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-130328: further speedup of pasting in new REPL on Windows by reading in chunks by chris-eibl · Pull Request #132889 · python/cpython

Conversation

@chris-eibl

@chris-eibl chris-eibl commented Apr 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is on top of #132884. So reviews should be done beginning with commit a64f4c4.

  • Issue: Pasting in new REPL is slow #130328

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chris-eibl added 6 commits April 24, 2025 18:02
@chris-eibl
fix WindowsConsole.wait()
0a38c2e
@chris-eibl
blurb it
05d26ff
@chris-eibl
fix timeout=None
cad6bfb
@chris-eibl
fix mypy for ctypes.get_last_error
3d1da66
@chris-eibl
fix return value of wait() and use it in _read_input()
4098e3d
@chris-eibl
read in chunks
a64f4c4
@chris-eibl
chris-eibl requested review from ambv, lysnikolaou and pablogsal as code owners April 24, 2025 20:45
@bedevere-app bedevere-app Bot added the awaiting review label Apr 24, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 24, 2025
Pasting in new REPL is slow #130328
Closed
@chris-eibl
fix missing return in getpending
937b6bd
chris-eibl
chris-eibl commented Apr 24, 2025
View reviewed changes
Comment thread Lib/_pyrepl/windows_console.py
"""Return the characters that have been typed but not yet
processed."""
return Event("key", "", b"")
e = Event("key", "", b"")

@chris-eibl chris-eibl Apr 24, 2025

Copy link
Copy Markdown
Member Author

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've just copy-pasted this from

cpython/Lib/_pyrepl/unix_console.py

Lines 536 to 555 in e1c09ff

def getpending(self):
"""
Get pending events from the console event queue.
Returns:
- Event: Pending event from the event queue.
"""
e = Event("key", "", b"")
while not self.event_queue.empty():
e2 = self.event_queue.get()
e.data += e2.data
e.raw += e.raw
amount = 10000
raw = self.__read(amount)
data = str(raw, self.encoding, "replace")
e.data += data
e.raw += raw
return e

and dropped the reading of the next chunk, since IMHO this does not fit the doc string.

mypy fires here

Lib/_pyrepl/windows_console.py:545: error: Item "None" of "Event | None" has no
attribute "data"  [union-attr]
                e.data += e2.data
                          ^~~~~~~
Found 1 error in 1 file (checked 25 source files)

and is indeed correct. Have to dig in why we do not see this in case of unix_console.py ...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chris-eibl chris-eibl added OS-windows topic-repl Related to the interactive shell labels Apr 24, 2025
chris-eibl
chris-eibl commented Apr 24, 2025
View reviewed changes
Comment thread Lib/_pyrepl/windows_console.py
return False
return True

def wait(self, timeout: float | None = None) -> bool:

@chris-eibl chris-eibl Apr 24, 2025

Copy link
Copy Markdown
Member Author

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.

Full in sync with unix_console.py now :)

cpython/Lib/_pyrepl/unix_console.py

Lines 419 to 427 in e1c09ff

def wait(self, timeout: float | None = None) -> bool:
"""
Wait for events on the console.
"""
return (
not self.event_queue.empty()
or self.more_in_buffer()
or bool(self.pollob.poll(timeout))
)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chris-eibl added 7 commits April 28, 2025 16:54
@chris-eibl
use self.paste_mode instead of self.in_bracketed_paste
bba26c9
in class Reader
@chris-eibl
Merge branch 'fix_wait' into read_chunked
9794664
to use self.paste_mode instead of self.in_bracketed_paste
in class Reader
@chris-eibl
Revert "use self.paste_mode instead of self.in_bracketed_paste"
3c0cae9
This reverts commit bba26c9.
@chris-eibl
Merge branch 'fix_wait' into read_chunked
b6ea252
to revert "use self.paste_mode instead of self.in_bracketed_paste"
@chris-eibl
Merge branch 'main' into read_chunked
8fa84d1
# Conflicts:
#	Lib/_pyrepl/windows_console.py
@chris-eibl
remove copying of the raw member of Event, because
5b055f1
it isn't used in the whole code, and some code paths in
WindowsConsole set it to str instead of bytes
@chris-eibl
Merge branch 'read_chunked' of https://github.com/chris-eibl/cpython …
a7ebeed
…into read_chunked
@chris-eibl chris-eibl mentioned this pull request May 2, 2025
gh-131507: Add support for syntax highlighting in PyREPL #133247
Merged
@chris-eibl chris-eibl closed this May 2, 2025
@chris-eibl

chris-eibl commented May 2, 2025

Copy link
Copy Markdown
Member Author

Closed because superseded by #133247 (comment).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl
chris-eibl deleted the read_chunked branch May 6, 2025 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@ambv ambv Awaiting requested review from ambv ambv is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review OS-windows topic-repl Related to the interactive shell

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@chris-eibl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.