gh-141968: Use take_bytes to simplify and remove copy from pyrepl BaseEventQueue#149852
gh-141968: Use take_bytes to simplify and remove copy from pyrepl BaseEventQueue#149852lgeiger wants to merge 5 commits into
take_bytes to simplify and remove copy from pyrepl BaseEventQueue#149852Conversation
…repl `BaseEventQueue`
|
cc @cmaloney |
1b0d030 to
bf42a7b
Compare
cmaloney
left a comment
There was a problem hiding this comment.
Happy to see .take_bytes() helping speed up more code!
| old = self.buf | ||
| self.buf = bytearray() | ||
| return old | ||
| return self.buf.take_bytes() # type: ignore[attr-defined, no-any-return] |
There was a problem hiding this comment.
the attr-defined shouldn't be needed here / if the type checker supports 3.15+ the attribute is always defined; not sure about the rest (I'd remove unless the in-repository mypy check requires)
There was a problem hiding this comment.
I only added it to make CI happy. See failure here. Maybe mypy's typeshed doesn't support it yet.
There was a problem hiding this comment.
It looks like it was just added to typeshed (python/typeshed#15724). Not sure what the process/timing is for updating the mypy/typeshed used in CPython PRs.
👍 on the comments for now and I'll work out if there's a better way for me to add the typeshed pieces in the future.
This PR uses
bytearray.take_bytesto simplify pyrepl'sBaseEventQueue.flush_bufand remove copies fromBaseEventQueue.push