gh-141968: Use bytearray.take_bytes() in more I/O paths - #156989
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟢 Approval recommended
Both changes preserve return types and behavior while safely eliminating unnecessary copies from locally owned bytearrays.
Pull request overview
Uses bytearray.take_bytes() to avoid final buffer copies in I/O and ZIP decryption paths.
Changes:
- Optimizes
_IOBase.readline(). - Optimizes legacy ZIP decryption output.
File summaries
| File | Description |
|---|---|
Modules/_io/iobase.c |
Transfers the readline buffer directly into bytes. |
Lib/zipfile/__init__.py |
Transfers decrypted output directly into bytes. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cmaloney
left a comment
There was a problem hiding this comment.
👍
I had a PR for the zipfile one previously (#142240). I think it is reasonable to do but hard to benchmark (the decrypter usage is uncommon).
For .readline() it probably makes sense to move entirely to PyBytesWriter (https://peps.python.org/pep-0782/). That is a separate larger scope change though.
8de25cb to
c4f4c75
Compare
|
OK. I used PyBytesWriter in #157024 |
Uh oh!
There was an error while loading. Please reload this page.