Repository navigation
Make Python list append and insert growth fallible - #10168
youknowdot wants to merge 7 commits into
Conversation
Carry forward the fallible list growth approach from coolreader18 in RustPython#3494 using the current VM MemoryError and Vec reservation paths. Assisted-by: Codex:GPT-6.2
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Continue the list portion of coolreader18’s RustPython#3494 using existing buffer reservations and keep Python behavior and locking unchanged. Assisted-by: Codex:GPT-6.2
Carry forward the exact-size iterator improvement in coolreader18’s RustPython#3494 without changing the slice interface. Assisted-by: Codex:GPT-6.2
Avoid the infallible intermediate source copy for list.extend and +=. Keep self-extension and subclass iteration behavior unchanged. Assisted-by: Codex:GPT-6.2
Codex Review Summary: ✅ CompletedThis 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. |
Copy live entries once under the source read guard and release it before allocating Python item tuples or growing the destination. Preserve the normal iterator path for subclasses. Assisted-by: Codex:GPT-6.2
Head branch was pushed to by a user without write access
Carry forward the original TryReserveError conversion; preserve the current prewarmed MemoryError and release the list guard before reporting failure. Assisted-by: Codex:GPT-6.2
Merging this PR will not alter performance
Comparing Footnotes
|
Reserve before mutation and copy already initialized prefixes as CPython does, with a fill for one-byte seeds. Keep the existing bytearray export checks and leave generic repetition unchanged. Assisted-by: Codex:GPT-6.2
Why
Carry forward the fallible list allocation work proposed by coolreader18 in #3494. The current VM already handles reservation failures in list extension and repetition, but append and insert still used infallible growth. CPython 3.15.2 propagates a failed list resize through its append and insert entry points.
Change
Scope of verification
The standard selectors for list operations/comprehensions, exception notes and GenericAlias directory output passed on both CPython 3.15.2 and RustPython on Linux (11 each). A bounded warm-up exercised both append opcodes; signatures and regular ZIP import also passed. The Rust unit check passed and tests a deterministic capacity rejection without requesting a real allocation. Full workspace, other platforms, C API, host allocator exhaustion and wall-time performance are not claimed.
Refs #3494.
Follow-up commits
Most remaining changes in #3494 were error-conversion API refactors rather than allocation changes. List extend already reserved its destination fallibly; this PR also covers the exact-list intermediate snapshot. In-place and ordinary sequence, byte and string repetition already reserve fallibly on main. The existing VM MemoryError mechanism is reused; this PR does not claim every RustPython allocation is recoverable.
Replacement scope for #3494
Summary by CodeRabbit