GeezerVison is showing github.com — traverse for generator by youknowone · Pull Request #6760 · RustPython/RustPython
Conversation
youknowone
commented
Jan 17, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Chores
- Improved garbage collection handling for async generators, coroutines, and generators to enable more efficient memory management.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Caution
Review failed
The pull request is closed.
📝 Walkthrough
Walkthrough
This PR adds manual garbage collection traversal support by implementing the Traverse trait for async generators, coroutines, generators, and the core Coro struct, while marking their pyclass definitions with traverse = "manual" to enable explicit GC tracing of contained fields.
Changes
| Cohort / File(s) |
Summary |
Async Generator Traversal crates/vm/src/builtins/asyncgenerator.rs |
Added unsafe impl Traverse for PyAsyncGen, PyAsyncGenWrappedValue, PyAsyncGenASend, PyAsyncGenAThrow, and PyAnextAwaitable; each implementation traverses its inner fields (Coro, finalizer, wrapped values). Updated all five pyclass definitions with traverse = "manual". |
Coroutine and Wrapper Traversal crates/vm/src/builtins/coroutine.rs |
Added unsafe impl Traverse for PyCoroutine (delegates to self.inner) and PyCoroutineWrapper (delegates to self.coro). Updated both pyclass definitions with traverse = "manual". |
Generator Traversal crates/vm/src/builtins/generator.rs |
Added unsafe impl Traverse for PyGenerator delegating to self.inner.traverse(tracer_fn). Updated pyclass definition with traverse = "manual". Added imports for Traverse and TraverseFn. |
Core Coro Traversal crates/vm/src/coroutine.rs |
Added unsafe impl Traverse for Coro struct that traverses frame, name, qualname, and exception fields. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- sys.set_asyncgen_hook #6439 — Modifies the same async generator types (PyAsyncGen, PyAnextAwaitable, PyAsyncGenASend/AThrow/WrappedValue) with lifecycle methods and state management
- PyAnextAwaitable #6427 — Introduces or modifies PyAnextAwaitable and async generator types alongside GC traversal additions
Poem
🐰 A rabbit hops through memory lanes,
Tracing coroutines' flowing chains,
Generators yield their GC care,
Traverse marks what's hiding there!
Cleanup bound, no leaks remain ✨
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Code has been automatically formatted
The code in this PR has been formatted using:
cargo fmt --all
Please pull the latest changes before pushing again:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|